Hello
Is there a way to save the items-information as JSON like the JSON we could see with ArcGIS Online Assistant?
Espacially I would like to store the "Web Map"-json to backup this information.
Cheers
Solved! Go to Solution.
You certainly can, checkout the `get_data()` method available on an `Item` object. You can make the `try_json` argument to False so you always download the JSON data.
The ArcGIS Online Assistant shows you both the item properties as JSON as well as the data resource as JSON. The `get_data()` gives you the latter. To get the item's properties as JSON, cast the Item object as a dictionary like below and write that to a file:
import json
my_item = gis.content.search("","Web Map")[0]
dict_my_item = dict(my_item)
with open ("path_to_webmap_json_file.json", "w") as file_handle:
file_handle.write(json.dumps(dict_my_item))
You certainly can, checkout the `get_data()` method available on an `Item` object. You can make the `try_json` argument to False so you always download the JSON data.
The ArcGIS Online Assistant shows you both the item properties as JSON as well as the data resource as JSON. The `get_data()` gives you the latter. To get the item's properties as JSON, cast the Item object as a dictionary like below and write that to a file:
import json
my_item = gis.content.search("","Web Map")[0]
dict_my_item = dict(my_item)
with open ("path_to_webmap_json_file.json", "w") as file_handle:
file_handle.write(json.dumps(dict_my_item))
Worked for me thank you!!
Once you get the json config data files for webmaps/webapps exported/backed up, is there a way to reimport them? I was looking at the additem or addpart API calls. What is the best way to do that?
Also, I know that I'll have to deal with updating the item IDs of web maps in the app configs (any ideas on best practices to do that)?
Can't wait until the ArcGIS online team can support backup/restore of entire orgs
Not sure what you mean by saying 'reimport'...
if you mean creating an item using the JSON you've got, yes you can. here is an example:
How To: Create a web map from a JSON file using ArcGIS API for Python