I'm currently in the process of converting some JSAPI 3.x code to 4.x.
It used to be you could do this in 3.x
//Use
esri/tasks/PrintParameters,
esri/tasks/PrintTask
//To get this
var params = new PrintParameters();
var webMapAsJSON = printTask._getPrintDefinition(<currentMap>, params);
webMapAsJSON could then be sent to a custom geoprocessing service using
var gp = new Geoprocessor("your service's url")
and manipulated to your heart's delight in Python on the back end.
Looks like "PrintTask" was deprecated back in 4.24... is there any way to still grab that JSON? I do not just want to send current state of web map to a layout using the new "print" module. I have all kinds of existing logic in arcpy that I want to apply before creating a PDF.