PrintTask Error first time executing task

2453
1
06-02-2016 02:55 PM
JohnPreston
Occasional Contributor

I get an error the first time I execute a print task on a page. This is error I get..."RequestError: Unable to Load /proxy/...<print task url>/execute status: 404." Despite getting error the first time I execute task, it works flawlessly after that. Am I missing something?

Here is code...

$("#btnPrintDefault").on("click", function () {                    

printUrl = "http://gisfarm.spokanecounty.org/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%...";                    

var printTask = new PrintTask(printUrl);                    

var template = new PrintTemplate();                    

var legendLayer = new esri.tasks.LegendLayer();                    

legendLayer.layerId = "roadLayer";                    

legendLayer.subLayerIds = [58, 117];                                        

template.format = "PDF";                   

template.layout = "Letter ANSI A Landscape";                    

template.layoutOptions = {                        

"titleText": "Spokane County",                        

"scalebarUnit": "Miles",                        

"legendLayers": [legendLayer]                    

};                    

template.preserveScale = true;                    

var params = new PrintParameters();                    

params.map = map;                    

params.template = template;                    

$('#mapPage').css("cursor", "progress");                    

printTask.execute(params, getPrinted, getPrintError);               

});

Tags (2)
0 Kudos
1 Reply
BillDaigle
Occasional Contributor III

Are you 100% sure you're proxy page is working correctly.  It sounds like it might be failing the first time because the request is getting through your proxy page.  Is it getting sent through the proxy the second time as well?  A look at the Network tab in your browser's developer tools should tell you one way or the other. 

0 Kudos