I have a python (ArcGIS Pro 3.3.2) script that created a raster file then published it to ArcGIS Online as a Tile Layer item using this series of instructions
sharing_draft = map_.getWebLayerSharingDraft("HOSTING_SERVER", "TILE", rest_id)
sharing_draft.serviceName = rest_id
sharing_draft.summary = snippet
sharing_draft.tags = tags
sharing_draft.description = description
sharing_draft.portalFolder = None
sharing_draft.overwriteExistingService = True
sharing_draft.credits = attribution
# Create Service Definition Draft file
sddraft_output_filename = os.path.join(arcpy.env.scratchFolder, rest_id + ".sddraft")
sharing_draft.exportToSDDraft(sddraft_output_filename)
sd_output_filename = os.path.join(arcpy.env.scratchFolder, rest_id + ".sd")
arcpy.StageService_server(sddraft_output_filename, sd_output_filename)
rsp = arcpy.UploadServiceDefinition_server(sd_output_filename, "HOSTING_SERVER")That works great but now I want have an updated raster and I want to overwrite the data original ArcGIS Online Tile Layer item. I thought that since I'm setting "overwriteExistingService" that it would work as is, but instead I get this error on the UploadServiceDefinition call:
arcgisscripting.ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Service name 'Access_to_Nature_Raster' already exists for 'dJOijx2lWTlGQBDJ'
Failed to execute (UploadServiceDefinition).
I looked inside the sddraft file to verify the the Type setting is 'esriServiceDefinitionType_Replacement'. What is the trick to making this work?