I'm trying to follow the steps in the Esri blog post Updating your hosted feature services with ArcGIS Pro and the ArcGIS API for Python but am running into an error.
To test this I published a simple stand-alone file GDB into an ArcGIS Online web map using ArcGIS Pro's UI tools. This creates a Service Definition, WebMap and associated Feature Layer on ArcGIS Online.
I then made a simple symbology change in ArcGIS Pro and attempted to push the updates to ArcGIS Online using the script. The script runs correctly as far as these lines:
sdItem = gis.content.search(query="title:"+ sd_fs_name + " AND owner: " + user, item_type="Service Definition")
I can confirm from the timestamps on ArcGIS Online that the Service Definition has been updated, but the script is falling over when trying to update the associated Feature Layer. The script contains this line:
fs = sdItem.publish(overwrite=True)
This gives me the error message
RuntimeError: User cant overwrite this service, using this data, as this data is already referring to another service
I can confirm that the data doesn't actually refer to another service since it's coming from a stand-alone file GDB that isn't used anywhere else. I'm using the same ArcGIS Online administrator's login within ArcGIS Pro and the Python script so I'm definitely the owner of the layer.
How can I overwrite the feature layer using the latest changes in the ArcGIS Pro document?