Using ArcGIS Javsacript API on one server to grab a PDF from a custom print service published on a different server. We have used the exact same script successfully on other apps/servers before with no problems. On a new server, however, we've run in to CORS issues, so we've tried both accepted approaches to dealing with this:

(1) Used working proxy (confirmed with other geoprocessing service in same app)

(2) esri.config.defaults.io.corsEnabledServers.push( [www.server.here] )

When using the first method (1), we initially get an esriJobFailed response. If we hit fire button again, it seems to submit the job as normal... seems strange.

If we use the second method, it submits the job fine.

At this point we are at the same step... PrintTask has been submitted and our web app is waiting for the response.

But we keep getting an "Unable to complete operation." error. When we look closely, it seems as if the PrintTask has successfully ran, but the result is not being delivered back to our app properly.

This screen shot shows a status 200 reponse with an "esriJobSucceeded" value:

successful print task

But if we look at the next request, it shows that we didn't make it to the finish line:

failure to complete

Neither of the callbacks functions for the PrintTask (success, error) fire.

But if we listen for each xhr request and find the one with the "esriJobSucceeded" value, we can construct the correct URL and load our PDF output:

var url = "http://server.com/arcgis/rest/directories/arcgisjobs/folder/printservice/" + resp.jobId + "/scratch/web_map.pdf"; 

This works, but it's obviously not what we want. Any thoughts on this?


Pretty basic callbacks. But the script doesn't even reach them.

gp1 = new PrintTask("http://server.com/arcgis/rest/services/App_Print_Service", {async: true});
gp1_params = new PrintParameters();
gp1_params.map = map;

function gp1_function() {
    gp1.execute(gp1_params, gp1_complete, gp1_error);

// GP Success
function gp1_complete(result) {

// GP Error
function gp1_error(error_info) {
    alert('Unexpected error');
  • can you show me part of callback ?? – Shiko May 12 '16 at 2:13
  • @Shady -- Posted callbacks. Nothing special, and the script doesn't even reach them. – Duncan Rager May 12 '16 at 20:05
  • Could you try the code here? desktop.arcgis.com/en/arcmap/latest/analyze/sharing-workflows/… – KHibma May 12 '16 at 20:17
  • @KHibma -- Which part of that link in particular? Seems like we have the same components presented in that tutorial. We've run the exact same setup I posted with success in other apps. The only difference is the proxy/CORS stuff. – Duncan Rager May 12 '16 at 20:26
  • The code in the javascript uses a PrintTask object, not a GP object which looks like what you're doing? – KHibma May 12 '16 at 20:28

None of the event handlers is fired is expected if you take a look into the handling logic source code of the ArcGIS js api which basically does not cover all the error cases. You may try listening the error event of the print task and see if any exception can be caught there.

Also, have you tried accessing the Output_File?f=json url in a new tab and see if it still failed. If it works, there may be some issues of the cors setting

You can also compare the problematic url with an url with successful response and see if there is any difference between the urls constructed by the print task, like the hostnames and the overall format.

I personally do not think the api could construct a mal-formated url but rather suspect the final request is directing to a different server rather than the actual ArcGIS Server.

May be you can provide us some url samples that we can help troubleshoot the problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.