Geoprocessing service not working

559
10
10-31-2021 05:41 PM
Aнастасия0328
New Contributor III

Hello community, I am stuck in setting up a geoprocessing service to export a web map. I am following ESRI tutorial to achieve this task. I managed to publish a geoprocessing service to ArcGIS server and used the sample JavaScript code with the URL to the geoprocessing service to build a web application to export the web map. However, what I can see by double clicking the html file is just a blank interface, not the web map.

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). A0328_0-1635726180287.png

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". 

A0328_1-1635726712137.png

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.

 

0 Kudos
10 Replies
LongDinh
Occasional Contributor II

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.

0 Kudos
Aнастасия0328
New Contributor III

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?

A0328_0-1635739227133.png

 

0 Kudos
LongDinh
Occasional Contributor II

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:

  • You have not published the toolbox with the appropriate template (i.e. the template is unreachable by the server at the UNC path that you set),
  • Your application's JS code is incorrect. Reference notes become outdated very frequently so check the JS code,
  • It is possible the template does not exist or was not published to AGS. Ensure the published template exists and that the toolbox has that as an option.

 

 

 

0 Kudos
Aнастасия0328
New Contributor III

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.

A0328_1-1635808085145.png

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...

A0328_2-1635808463367.png

 

0 Kudos
LongDinh
Occasional Contributor II

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.

0 Kudos
Aнастасия0328
New Contributor III

Thanks again,

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. 

0 Kudos
LongDinh
Occasional Contributor II

The JavaScript code is not working. The request appears to never have been sent.

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?

0 Kudos
Aнастасия0328
New Contributor III

Thank you for pointing out the cause. 

I have opened the console but don't understand the messages unfortunately.

A0328_1-1635813625569.png

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?

 

 

 

0 Kudos
LongDinh
Occasional Contributor II

What's the endpoint of the url which you added to the print widget? It should look something like: 

https://webadaptorhost.domain.com/webadaptorname/rest/services/Utilities/PrintingTools/GPServer/Expo...

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-...

0 Kudos