Getting error when trying to Create Buffer using Analysis Services

12-28-2021 01:15 PM
Occasional Contributor

I'm trying to create a buffer of all parcels with 100 Meters of the National Interstate systems. I'm using a national feature layer of parcels, and selecting based on the Living Atlas USA Freeway System feature layer. I'm following the workflow at The key code is: 

host_url = ""
portal_url = "{}/sharing/rest".format(host_url)
token = get_token(portal_url, username, password)
analysis_url = get_analysis_url(portal_url, token)
task = "CreateBuffers"
output_service = "CreateBuffers_I95"
params= { "inputLayer": {"url": ""},
"method": "Geodesic",
"spatialRel": "withinDistance",
"selectingLayer": "",
"distance": 100.0,
"units": "Meters",
"dissolveType": "Dissolve",
"outputName": {"serviceProperties": {"name": "LocationQueryResult"}
task_url, job_info = analysis_job(analysis_url, task, token, params)
job_info = analysis_job_status(task_url, job_info, token)
job_values = analysis_job_results(task_url, job_info, token)

When I run it I get :

Logging in
Getting token...
Getting Analysis URL...
Submitting analysis job...
{'jobId': 'jaf04b394ba164b9d8de5098228b2d6c3', 'jobStatus': 'esriJobSubmitted', 'results': {}, 'inputs': {}, 'messages': []}
{'jobId': 'jaf04b394ba164b9d8de5098228b2d6c3', 'jobStatus': 'esriJobFailed', 'results': {}, 'inputs': {}, 'messages': [{'type': 'esriJobMessageTypeError', 'description': '{"messageCode": "AO_100012", "message": "CreateBuffers failed."}'}, {'type': 'esriJobMessageTypeError', 'description': 'Failed to execute (CreateBuffers).'}, {'type': 'esriJobMessageTypeError', 'description': 'Failed.'}]}
Exception                                 Traceback (most recent call last)
<ipython-input-34-708507b739fa> in <module>
    175         }
    176 task_url, job_info = analysis_job(analysis_url, task, token, params)
--> 177 job_info = analysis_job_status(task_url, job_info, token)
    178 job_values = analysis_job_results(task_url, job_info, token)

<ipython-input-34-708507b739fa> in analysis_job_status(task_url, job_info, token)
    112                 print(job_response)
    113                 if job_response.get("jobStatus") == "esriJobFailed":
--> 114                     raise Exception("Job failed.")
    115                 elif job_response.get("jobStatus") == "esriJobCancelled":
    116                     raise Exception("Job cancelled.")

Exception: Job failed.

There's very little here to go on for troubleshooting, any ideas to try and overcome this are most welcome!

Thanks in advance or any replies and insights!


0 Kudos
1 Reply
Esteemed Contributor

Can you try setting this up in ModelBuilder and then export to python after successful ran and compare to your code?

0 Kudos