Select to view content in your preferred language

updating agol service definition

525
0
01-04-2018 01:10 PM
MikeHay
Emerging Contributor

I'm trying to debug the script described at:
https://blogs.esri.com/esri/arcgis/2017/03/14/updating-your-hosted-feature-services-with-arcgis-pro-...

on line 41, if I use:
sdItem = gis.content.search("{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]
Then the wrong service definition is returned, because the name query is not strict enough. The only way to get the correct service definition is to use the id instead of owner or title, e.g.
sdItem = gis.content.search(query="title:"+ sd_fs_name + " AND id:" + serviceItemID, item_type= "Service Definition")[0]

but this throws the error: IndexError: list index out of range

The correct service definition can be returned without an IndexError if item_type is not included;
sdItem = gis.content.search(query="title:"+ sd_fs_name + " AND id:" + serviceItemID)[0]

but then line 45 fs = sdItem.publish(overwrite=True) throws:

File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis.py", line 3125, in publish

if fileType == 'shapefile':
UnboundLocalError: local variable 'fileType' referenced before assignment

Does anyone have any ideas on how to both get the correct service definition, and also specify item type? I've tried many different permutations of the different arguments.

0 Kudos
0 Replies