Select to view content in your preferred language

arcgis.gis.Item.get_data() returns None

10-23-2019 03:20 PM
New Contributor III

I am adding a hosted feature layer by zipping a file geodatabase, adding it using gis.content.add, then publishing the layer. I am then retrieving the layer using, getting the item, and then trying to use item.get_data(try_json=True). It is returning None, which from the documentation I can see says that 'Zero byte files will return None'. I am unsure why there is no data returning. I can add the layer to a map, display it, etc...but cannot get the data to return for the layer. Has anyone else dealt with this issue?

layer_title = <title>

url = ""
username = <username>
password = <password>
gis = GIS(url, username, password)

layer_properties = {'type': 'File Geodatabase', 'title': <title>}

#add file gdb
layer = gis.content.add(item_properties=layer_properties, data=outfile) # outfile is the zipped file gdb

#publish item
layer_item = layer.publish()

#delete zipped folder

layer_search ="title: {}".format(layer_title), item_type="Feature Layer")
item = layer_search[0]

item_data = item.get_data(try_json=True)

Tags (3)
0 Kudos
2 Replies
New Contributor II


I have been trying to do the same thing which is to get the feature layer into a json format but still unsuccessful.. Is there an update for this?


item = gis.content.get(hosted_feature_layer_id)
jsonItem = item.get_data(try_json=True)



Thank you,


0 Kudos
Esri Contributor

Hi Trace Stanford‌, 

You can use the get_data() to get JSON format for the WebMaps and WebScenes items. But it has various results for other items. 

arcgis.gis module — arcgis 1.7.1 documentation 

The get_data returns an object based on the content type of the data. For non-JSON/text data, binary files are returned and the path to the downloaded file. For JSON/text files, a Python dictionary or a string. All others will be a byte array, that can be converted to string using data.decode(‘utf-8’). Zero byte files will return None.

You can check this post if you want to download the Feature Service item use extract_data tool.

Download Item Data 

There is an example page with different usage for get_data() on different item types. 
Clone Portal users, groups and content | ArcGIS for Developers 

~Vicky Wang~