[GIS] Error code 500, error performing execute operation from Print task of ArcGIS API for JavaScript

arcgis-javascript-apiprintingweb-mapping

I'm trying to use print task to generate a PNG or PDF file of my web map but i always get an Error code 500, error performing execute operation.

Any Ideas?

I'm using ArcGIS API for JavaScript 3.2.0

var dojoConfig = { async : true };

on(dom.byId("png"),'click', function () {
printTaskSetup("MAP_ONLY", "png32");
})
on(dom.byId("landscape"),'click', function () {
printTaskSetup("A4 Landscape", "PDF");
})
on(dom.byId("portrait"),'click', function () {
printTaskSetup("A4 Portrait", "PDF");
})

function printTaskSetup(layout, format){
var template = new esri.tasks.PrintTemplate(
template.format = format;
template.layout = layout;
template.layoutOptions = {
 "scalebarUnit": "Miles",
 "copyrightText": "Clerk",
 "showAttribution": false
}
template.preserveScale = true;
var params = new esri.tasks.PrintParameters();
params.map = map;
params.template = template;
printTask = new esri.tasks.PrintTask(print URL, dojoConfig);
printTask.submitJob(params, printResult, printError);
}
function printResult(result) {
  window.open(result.url)
}
function printError(error) {
  alert(error);
}

Best Answer

it could be more than one thing, but my guess is that you're calling 'execute' and the print task is actually set up as asynchronous or 'submitJob' and its synchronous

in order to tell for sure, browse the REST services directory to see what operation the service actually supports and compare that to the URL that 500s.

if thats the problem, you can set sync/async in the PrintTask constructor parameters.

https://developers.arcgis.com/javascript/jsapi/printtask-amd.html#printtask1