arcgisjobs URL

1263
4
Jump to solution
11-20-2012 01:40 PM
DaveHighness
Occasional Contributor II
Hi, I've been trying to figure out the URL to download a PDF that I create in a GP Script that gets put into the Jobs folder. I can see that PDF in the folder but I cannot figure out the URL to download it.

Physical Path:
D:\arcgisserver\directories\arcgisjobs\gptasks\createpdf_gpserver\jdbb9112ceca04162ba591391b5151305\scratch\EditorMap_20121120_141837.pdf

What I think the URL should be:
http://sitehost:6080/arcgis/rest/directories/arggisjobs/gptasks/createpdf_gpserver/jdbb9112ceca04162...

From the help I think this should do it. I always get an "Error Code:500" back from the ArcGIS REST Framework. What am I doing wrong?

Thanks, Dave
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KevinHibma
Esri Regular Contributor
You dont have to pass any URLs in your Python code -all the parameter output locations between the service and the REST are handled by the framework.

By setting a file as the output type in your Python script / tool, (using the SetParameterAsText), it just comes back. You dont need to worry about URLs and virtual directories here.

If you have a tool that runs fine inside ArcMap and returns a PDF, and then you publish it as a service and THAT runs fine when you consume it in ArcMap, you've done everything you need.

All you need to do is to get the output in your javascript application.

From the first link's web application, the code to do this:

function gpJobComplete(jobInfo) {     if (jobInfo.jobStatus == "esriJobSucceeded")     { gp.getResultData(jobInfo.jobId, "Output"); }       else {           showDialog(dojo.string.substitute('<a href=${url} target="_blank">Job failed</a>', { url: gp.url + "/jobs/" + jobInfo.jobId }));         } }  function gpResultDataComplete(result) {     showDialog(dojo.string.substitute('<center><a href=${url} target="_blank">Download Map</a></center>', { url: result.value.url })); }

View solution in original post

0 Kudos
4 Replies
KevinHibma
Esri Regular Contributor
I guess two things to check here -
1) how does the script pass the output back? I assume you have an output parameter of File (which maps to GPDataFile) in REST. Inside the script you have something like
arcpy.SetParameterAsText(10, myPDFoutputVar)


2) How are you consuming it where it doesn't come back? Sounds like REST or a web application. If you consume your service back in Desktop, can you open the Results window and double click the output under the service result to open the PDF? If you can, then everything you've done in question 1 above is correct.
These two arcgis.com links have nice simple web applications which you could use to compare against your code to see if you're asking for the PDF back correctly:
http://www.arcgis.com/home/item.html?id=442e1c7ff64240af8f41825f567e60d0
http://www.arcgis.com/home/item.html?id=8f16fdeef39c46b3952002b2d85ea5de
0 Kudos
DaveHighness
Occasional Contributor II
Yes, this is an Asynchronous GP Task run from the JS API and I need to pass the PDF URL back as an output parameter. I am doing just what you show above but I don't know how to get the URL of the "arcgisjobs" folder to set the "myPDFoutputVar".

My app is similar to the 2nd example above but I need to make the PDF available from a URL not just copy it to C:\Temp. I thought that the "arcgisjobs" folder was supposed to be web accessible.

Thanks, Dave
0 Kudos
KevinHibma
Esri Regular Contributor
You dont have to pass any URLs in your Python code -all the parameter output locations between the service and the REST are handled by the framework.

By setting a file as the output type in your Python script / tool, (using the SetParameterAsText), it just comes back. You dont need to worry about URLs and virtual directories here.

If you have a tool that runs fine inside ArcMap and returns a PDF, and then you publish it as a service and THAT runs fine when you consume it in ArcMap, you've done everything you need.

All you need to do is to get the output in your javascript application.

From the first link's web application, the code to do this:

function gpJobComplete(jobInfo) {     if (jobInfo.jobStatus == "esriJobSucceeded")     { gp.getResultData(jobInfo.jobId, "Output"); }       else {           showDialog(dojo.string.substitute('<a href=${url} target="_blank">Job failed</a>', { url: gp.url + "/jobs/" + jobInfo.jobId }));         } }  function gpResultDataComplete(result) {     showDialog(dojo.string.substitute('<center><a href=${url} target="_blank">Download Map</a></center>', { url: result.value.url })); }
0 Kudos
DaveHighness
Occasional Contributor II
Arg, okay. That has never been obvious to me that you just set the output parameter to type File and ArcServer would return the URL to the file. I wish that there were more ways to do the same thing. Something like the following would make more sense in my feeble mind.

outfldr = arcpy.env.scratchWorkspaceUrl


Thanks for the help.

Dave
0 Kudos