ArcGIS Online content cannot be exported through function

321
0
05-18-2021 11:40 AM
Manu
by
Occasional Contributor

I tried to download some ArcGIS Online content as Shapefile from Python. When I set the parameters manually, it downloaded the shapefile as .zip. However, when calling the function, it returned the

Spoiler
error:downloadShapefiles(plot_id = plot)
Unable to export item.
Item type'file' is not supported for export, The item needs to be of type url
Item '3bf5df57ab464b2c9855e797fd3ba24f' is of invalid type 'Service Definition' Item type for export needs to be 'Feature Service', 'Vector Tile Service' or 'Scene Service'
(Error Code: 400)

The function is just:

Spoiler
def downloadShapefiles(plot_id):
  try:
       # Search items by username
       cont = gis.content.search("owner:{0}".format("MyName"))
       for shp in cont:
                 if plot_id in shp.title:
                           shapefile = shp.export("layer {}".format(shp.type), "Shapefile")
                           shapefile.download(dir_shp(plot_id))
                           shapefile.delete()
       except Exception as e:
                 print(e)

Which was modified a bit from the ArcGIS examples.
When I set plot_id manually and shp = shps[2] (which is an instance where the condition plot_id in shp.title is met), it downloaded without problems.

What went wrong here?

0 Kudos
0 Replies