Help downloading WebMaps/WebApps as JSON files

751
0
05-12-2022 12:06 AM
Labels (1)
LindsayRaabe_FPCWA
Occasional Contributor III

HI All. I've been looking at a couple of backup tools in the ArcGIS Online Marketplace and whilst I'm happy that the one I've trialed does a pretty decent job of downloading all of our content to a local folder for backup purposes, my management want me to try scripting it in-house first. 

I'm already download feature services as feature classes in GDB's on a daily basis to capture changes to data for restoration after accidental deletion, but I'd like to go a step further. 

I've been looking at the ArcGIS API for Python site and tried the following script (to no avail). Can anyone point out how I might be able to download both WebMaps and WebApps as JSON files, so that if they ever get deleted, we could republish them?

 

from arcgis import gis 
from arcgis.gis import GIS
    
### Access the stored password with keyring and sign into the GIS      # https://community.esri.com/t5/arcgis-online-blog/connect-to-the-gis-in-python-scripts-without/ba-p/889867
import keyring
pw = keyring.get_password("ArcGISOnline", "Username")
gis = GIS("https://maps.arcgis.com", "username", pw)
print("Connected to the GIS")

item = gis.content.get('item_ID_here')
print (item)
item.get_data()
print (item)

 

Supposedly the get_data() line will download the item (or it's content?) to the default temp folder, but I can't see anything appearing (%temp% in File Explorer). ArcGIS API for Python: Managing your content (downloading-your-items) 

Cheers!

Lindsay Raabe
GIS Officer
Forest Products Commission WA
0 Kudos
0 Replies