When programmatically publishing Map Image Services to ArcGIS Enterprise Portal, it is possible to define the service's title (the one which will be displayed in the item’s portal page after publishing) by modifying the .sddraft file. Please find an example below:
layer_sharing_draft = map.getWebLayerSharingDraft(target_server_type, "MAP_IMAGE", service_name)
# Create Service Definition Draft file
# Modify title in sddraft file
xml_sddraft = DOM.parse(sddraft_file_path)
title = xml_sddraft.getElementsByTagName('Title')
title.firstChild.data = service_title
# save as new sddraft file
with codecs.open(new_sddraft_path, "w", "utf-8") as f:
# stage service
sd_file = arcpy.StageService_server(new_sddraft_path, sd_file_path)
# upload service definition
While this works when creating services, it does not work when overwriting them. (when layer_sharing_draft.overwriteExistingService = True)
So when I overwrite an existing service, the title in the variable "service_title" is not shown as title in the service's portal page as I would expect.
The question is: Is it possible to edit the .sddraft file in such a way that the service title is changed when overwriting the service? Or is there another way to accomplish this?