I'm trying to add a new item to ArcGIS Online with predetermined item json. I thought I could do this by referring to my json file in the `data` value, so something like :
gis.content.add(item_properties, data='/Users/cour7816/data.json')
That's not working for me. I've also tried using another item's URL for data - no dice.
Is there another way to achieve this?
Solved! Go to Solution.
Courtney, you need to send the json as a kvp in the item_properties dictionary. You can read the json and pass it as a string (use json.dumps()). See below for an example.
import json
json_file = json.loads('your_json.json')
item_properties = {'title':'Web scene with photo realistic buildings',
'type':'Web Scene',
'snippet':'This scene highlights buildings of Montreal, Canada',
'tags':'ArcGIS Python API',
'text': json.dumps(json_file)}
web_scene_item = gis.content.add(item_properties)
Courtney, you need to send the json as a kvp in the item_properties dictionary. You can read the json and pass it as a string (use json.dumps()). See below for an example.
import json
json_file = json.loads('your_json.json')
item_properties = {'title':'Web scene with photo realistic buildings',
'type':'Web Scene',
'snippet':'This scene highlights buildings of Montreal, Canada',
'tags':'ArcGIS Python API',
'text': json.dumps(json_file)}
web_scene_item = gis.content.add(item_properties)
Perfect! Thank you for your help!