I'm performing a batch download from my AGOL account, and using the ESRI documentation export item
I can export content to shapefiles. I would like to then download the newly created shapefiles. In order to accomplish this I have to be able to have the ID number of the newly created shapefile. According to the documentation it is in the JSON response.
sudo code:
import requests
import arcrest
import json
exporturl = self.root_url +'/users/' + self.username + '/export'
export = requests.post(exporturl, params=FsParams)
export_response = export.json()
What I have tried:
response = export_response['exportItemId']
print response
Error: KeyError: 'exportItemId'
printing response = export_response
returns the params
from the post
Using the requests
library can I access the JSON response? If this is not possible with requests
what method will work?
export_response
andexport
prints out? Based on your code (looking at it, not trying it), if your URL is correct you should be getting a response.However, a guess might be your syntax ofexport.json()
is wrong, it should beexport_respone =json.loads(export)
(but just a guess as I stopped using requestsjson.loads()
as that does not work. I modified the the OP with the errorprint export_response
and see all the key:values. This will tell you either your initial request is wrong, or hopefully something useful to help you debug in the returned responseexport_response
exposed an issue with my first two layers.response = export_response['exportItemId']
worked once I put it in atry
clause. If you move that to an answer Ill accept it.