updating agol service definition

Discussion created by InyoCounty on Jan 4, 2018

I'm trying to debug the script described at:


on line 41, if I use:
sdItem ="{} 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 ="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 ="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\", 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.