Select to view content in your preferred language

How to update ArcGIS Online Hosted Tile Layer

139
1
3 weeks ago
DonMorrison1
Frequent Contributor

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?

0 Kudos
1 Reply
BrandonMcAlister
Frequent Contributor

So I have had a lot of trouble overwriting web feature layers, since it is just the generic 999999 error try adding something like aprx.save() if you are publishing from an arcgis pro project. Ensure that the source layer id's are the same and map layer id are the same. Even with unique layer id's checked; if those were not the same I would get issues publishing. 

 

The rest of your code looks exactly like mine, so must be gremlins

Thanks,
Brandon
0 Kudos