Hi Guys,
I have a python code to publish and overwrite a hosted feature layer to AGOL from my ArcGIS Pro project. The Problem is when i run the code to overwrite the Hosted Feature Layer with Updated Data, The Sharing Level of that Feature layer in AGOL becomes "Organization only". I need to go to the AGOL organization and manually i need to set the sharing level to Public every time. Since i am using that layer for a public web map and Web App , the layer needs to be public. My codes are as following:
# Create FeatureSharingDraft and set overwrite property
server_type = "HOSTING_SERVER"
sddraft = m.getWebLayerSharingDraft(server_type, "FEATURE", service_name)
sddraft.overwriteExistingService = True
sddraft.credits = "These are credits"
sddraft.description = "This is description"
sddraft.summary = "This is summary"
sddraft.tags = "tag1, tag2"
sddraft.useLimitations = "These are use limitations"
sddraft.portalFolder = "01 My DevOps"
sddraft.allowExporting = False
sddraft.enable_sync = True
print("~~Metadata Updated Done~~ Overwrite Enabled")
# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)
print("SD draft File Creation Done")
# Stage Service
print("Staging Started ...")
sddraft.overwriteExistingService = True
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)
print("~~Staging Done~~")
# Share to portal
print("Uploading Started...")
arcpy.server.UploadServiceDefinition(sd_output_filename, server_type)
print(" Done! ~~ Hosted Layer Re - Published ~~Congrats")
I assume if inthe sddraft there could be a function to solve this. I did not find any documentation on this searching the ArcGIS Python documentation or arcpy. Is there a Solution?
My Goal is to overwrite the hosted feature layer as a publicly shared feature layer.
--best
Ashad