I have been comparing this tutorial with other ESRI learning source such as ESRI video (13:04). I found that this tutorial uses "Optional" for "Web_Map_as_JSON" in parameter setting of the script tool whereas the video uses "Required" for "Web_Map_as_JSON" parameter (please see screen shot below).
As ESRI's tip in the tutorial says that we can leave the input parameter for Web_Map_as_JSON blank, the script tool won't run successfully if I change the parameter to "Required".
I don't know if this difference is the cause of my problem but I have not been able to find any other potential cause yet. I appreciate If anyone points out a cause of my problem and give me some advice.
Thanks in advance.
Hi @Aнастасия0328 ,
It may be empty because you have not set a basemap in your layout template or a basemap in your Web_Map_as_JSON object does not exist.
If you are not sending any features to print, it will should print the basemap of the layout template if you have that set in your layout template. When you published the Printing Geoprocessing Service, did you add a default basemap?
In your browser's developer tools, check the Network tab for the post body json parameters of the printing task url request is actually sending what you expect to see e.g the Web_Map_as_JSON object contains the relevant property values (operationalLayers and baseMaps)).
See ExportWebMap Specification for the expected object in your request.
Hi LongDinh, thanks for your advice.
I think I have set a basemap by changing the path to the folder that contains the template mxd file. The line below is ESRI sample code in the tutorial, so I updated the path in the line to suit my case and the folder is registered.
# The template location in the server data store templateMxd = r"\\MyComputer\MyDataStore\BasicTutorial\v103\WorldTopo_103Templatev2_288k_to_1k.mxd"
I feel what you said "a basemap in Web_Map_as_JSON object does not exist" may be happening in my case. As you mentioned, I opened the Network tab but I don't know what I am supposed to do next. Could you please tell me what I should do next?
Have the html file open and open your developer tools to the network tab. Next hit the print button
A request to the printUrl as coded in the JS sample will appear with details of the request parameters sent to the server.
Select it and scroll down to the Request Parameters. There should be a Web_Map_as_JSON parameter which is the web map (as JSON) object you sent to the server. Inspect it to see if it is what you expected.
If it is not what you expected, it can be any of the following:
Do you mean a print button for the "Next hit the print button" is this one? I did hit but it did not happen anything.
Although I was not sure if this is the one you meant, I also changed the setting of "Emulate CSS media type" to "print". But it still does not show the details of the request parameters. I guess I am not doing what you mentioned...
Hi @Aнастасия0328 ,
I am referring to the print action in your web browser/HTML application. The developer tools will track the web request that you send to the server.
Simply, try printing/exporting the web map in your application while developer tools is open. When you have sent the request, the network tab will update with a new row - your request to the printTaskUrl labelled execute or submitJob.
Select the network activity and review the request parameters.
When you have received the printed Web Map url in your HTML application, a new row should appear indicating a network response from the server.
Actually, the first picture is the one with the print button in my html application. while the developer tool is open, I hit the print but it did not happen anything.
Check the console tab to see if anything has been logged.
Are you able to test this on Portal or ArcGIS Online using the the Web Application Print Widget?
Thank you for pointing out the cause.
I have opened the console but don't understand the messages unfortunately.
I also tried to add a print widget to Web Application Builder with the service url. But error came up, saying "This URL is not a print task". Maybe this is because I used ArcPy.mapping for the script tool rather than ArcPy.MP?
What's the endpoint of the url which you added to the print widget? It should look something like:
You can follow these reference notes.
The console error appears to not accept your machine's domain. You can enable it following this https://enterprise.arcgis.com/en/portal/latest/administer/windows/restrict-cross-domain-requests-to-....