AnsweredAssumed Answered

Update Service Definition on AGOL

Question asked by InyoCounty on Jan 5, 2018
Latest reply on Jan 28, 2019 by InyoCounty

Using the script at this blog:

Line 41: sdItem ="{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]
returns the wrong Service Definition (SD). The title query is not strict enough, so it returns any SD with a "Z" in the title. The SD I'm looking for is Zoning.


Title or owner can be replaced with id:
sdItem ="title:"+ sd_fs_name + " AND id:" + serviceItemID, item_type= "Service Definition")[0]
which throws: IndexError: list index out of range

Many permutations have been tried for using ID.

If item_type= "Service Definition" is removed, line 41 will run:
sdItem ="title:"+ sd_fs_name + " AND id:" + serviceItemID)[0]

However, then on line 45: fs = sdItem.publish(overwrite=True)
it 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


So, the question is - how do I specify the ID, and also specify the item type?