AnsweredAssumed Answered

Update Webmap (json) with Python

Question asked by n.ueberschaeresri-rw-esridist Employee on Mar 28, 2017
Latest reply on Mar 29, 2017 by n.ueberschaeresri-rw-esridist

I would like to update a webmap through json with Python. I know that I could use the AGOL Assistant to change the json of a specific webmap but just as an example: If I want to change the same thing in all of my webmaps (e.g. changing a layer or a bookmark name or the bookmarks in general...) it would be more comfortable to "grab" all my webmaps from my AGOL content, make the changes (at the moment I'm just replacing for example "Berlin" as a bookmark name by "Berlin, Germany") and update my webmaps in AGOL. 

 

I have seen this ArcGIS REST API Update function but I don't understand how to use it. 

I have tried update-webmap-json at master · from GitHub but I don't see at which point I should apply my edits to the json in order to see if anything happened when doing the update. Did anyone manage to work with this?

I learned thanks to this post Edit or update ArcGIS Online Web Map data using the REST API that I can pull the data with http://www.arcgis.com/sharing/rest/content/items/ITEMID/data and should be able to update with http://www.arcgis.com/sharing/rest/content/users/USER_ID/items/ITEM_ID/update. 

 

I attached my script in case someone feels like testing. 

Here is in brief what I do with my script: 

  • set username and password
  • define (for testing) which webmap to take
  • Read map(s) from Content and save to mxd and json
  • Before updating I open the json, do my changes, save it to the same file.
  • At the next step I am not sure which "stage" of the json I have to use to upload it and I don't really understand what lines from line 51 are actually doing. Maybe someone can point me where this actual update request is better described. 
  • The result is that my script runs smoothly showing all the prints, no errors, but when I check the bookmark in my webmap that I intended to change it is still the same. 

 

Thank you very much in advance!

Outcomes