Request data from ArcGIS Server through python

09-08-2017 12:45 PM
New Contributor III

I am having an issue when trying to create a script that will return a list of values from an ArcGIS Server service from a json query in python. I have the following code below which I thought would do the trick but it returns the HTML and not the json results as I was hoping. Could someone please help to let me know what I'm doing wrong?

import requests, json

inFeatures = ""
json_payload = { 'where': 'acres > 5','f': 'json', 'outFields': 'latitude,longitude,incidentname,acres'}
r = requests.get(inFeatures, params=json_payload)
print r.text
0 Kudos
1 Reply
Esri Notable Contributor

If you make that request manually in your browser, some sort of token is attached to the request: 

Since you're not submitting the request with that token, it redirects you to an HTML page.