AnsweredAssumed Answered

How to use a web geoprocessing service

Question asked by wwmiller68 Champion on Jul 23, 2015
Latest reply on Aug 4, 2015 by wwmiller68

I'm trying to use a web geoprocessing service in python. I'm using the example in this web site

I'm not getting the expected results does anyone know the proper syntax to submit a job to a geoprocessing service?


Here's my code:

import arcpy,urllib,json

baseURL = "my service here"

query = "?Address:=504 Walnut St & RecType: = Youth Baseball League?"

submitResponse = urllib.urlopen(baseURL+query)
submitResponse = urllib.urlopen(baseURL+query)
jobUrl = submitResponse.geturl()
status = "esriJobSubmitted"
print jobUrl
while status == "esriJobSubmitted" or status == "esriJobExecuting":
    #print "checking to see if job is completed..."
    jobResponse = urllib.urlopen(jobUrl, "f=json")
    jobJson = json.loads(
    if 'jobStatus' in jobJson:
        status = jobJson['jobStatus']
        if status == "esriJobSucceeded":
            if 'results' in jobJson:
                resultsUrl = jobUrl + "/results/"
                resultsJson = jobJson['results']
                for paramName in resultsJson.keys():
                    resultUrl = resultsUrl + paramName
                    print resultUrl
                    resultResponse = urllib.urlopen(resultUrl, "f=json")
                    resultJson = json.loads(
                    print resultJson['value']
                    print resultJson
        if status == "esriJobFailed":
            if 'messages' in jobJson:
                print jobJson['messages']
        print "no jobId found in the response"
    print "no jobId found in the response"


Message was edited by: Wes Miller