Select to view content in your preferred language

Get JSON response with ArcGIS API for Python

148
2
12-04-2024 04:44 AM
JamesTurner2
Regular Contributor

I have a script to generate Survey123 feature reports, I used this method to create it: https://developers.arcgis.com/survey123/guide/create-reports-using-the-arcgis-api-for-python/

I want to be able to access some of the information that you see in the "recent reports" section of the Survey123 web app. Mostly, I want to get the 'messages' section and incorporate that into the script for debugging.

JamesTurner2_0-1733315761154.png

With the above example, in my script the only output I receive is: 

ERROR: KeyError:  'NoneType' object has no attribute 'seek'  (related to ESRI BUG-000119057)

It is not all that helpful, but when I go to the recent reports page in the web app, I see that the actual problem is that the query I used returned no results. So I want to be able to display these messages in my script.

It looks like this information is available in the JSON response if you are using the Rest API, but maybe not with ArcGIS API for Python? I might have terms confused here, I don't have grasp between the difference of ArcGIS API for Python and the REST API

0 Kudos
2 Replies
ChristopherCounsell
MVP Regular Contributor

Alternatively, add a line of python to run the query against the layer, then if results exist create the report / else return a message saying the object was not found?

0 Kudos
JamesTurner2
Regular Contributor

Thanks, that's a good alternative. I'm not sure what other kinds of messages might appear in the JSON and if they would be helpful, but this is a good work around for the time being and a good way to catch one of the possible errors. Thanks for the input!

0 Kudos