ArcGIS Geoprocessing – Accessing Geoprocessing Service via REST to Get JSON Response

arcgis-10.0arcgis-rest-apiarcgis-servergeoprocessingrest

I have an ArcGIS Server 10.0 geoprocessing task with a REST endpoint something like this:
http://server/arcgis/rest/services/MyService/GPServer/MyTask

The task takes a parameter. I was hoping I could pass it like so:
http://server/arcgis/rest/services/MyService/GPServer/MyTask?param=Value&f=pjson

… and get the result back as JSON. But it doesn't seem to respond to the parameter – all I get is static metadata about the task. There is the option of submitting a job, but my JavaScript will have no idea when it finishes, so I would have to keep checking the job till it's done and then get the results via individual URLs:

http://server/arcgis/rest/services/MyService/GPServer/MyTask/jobs/a72h72hd6d6g26gdh7/results/someParam?f=pjson

Is there really no way to just get the results as JSON? And pass the parameter in the first place?

Best Answer

You should have a look at the REST Help for GP Task

To run the geoprocessing task, you need to provide an input. If your GP Service is Synchronous, then you need to call the Execute Operation. If your service is Asynchronous, then you need to call the SubmitJob Operation. Both of them take their input parameter in JSON Format.

In the case of a Synchronous service, you get the response directly.

In the case of an Asynchronous Service, you get a jobid back. You need to query the status of the job Id, and once the process is complete, you can get the results, by querying the GP Result Operation.

All of this can be done through simple Get resquests and JSON format

Related Question