Select to view content in your preferred language

getWebLayerSharingDraft - sharing to a group?

260
0
03-09-2025 10:09 PM
MicZatorsky_AEC
Frequent Contributor

Does anyone know of a problem or bug getting getWebLayerSharingDraft to share to a defined group on ArcGIS Online using arcpy, as shipped with ArcGIS Pro 3.4.2.

My code effectively has a single group:

sddraft.sharing.groups = "Flood Modeling - Working GP"

The service is being successfully published, but it has not been shared with the specified group. I'm not seeing any errors or warnings.

Is there a bug?  A problem with spaces or hyphens?  Does it need to be a Python list?   Are any other parameters causing a conflict? Unicode?

If the service exists, the overwriting is honoured, but the new item is effectively unshared when the overwrite occurs.

Here is a snippet of my code :

 

 

 

 

# Set publishing metadata and parameters
    service_type = "FEATURE"
    service_name = map_name

    credits = "X, Y"
    description = f"{map_name}.IFC"
    summary = f"Published by MZ {timestamp}"
    tags = "TEST"
    useLimitations = "None"
    portalFolder = "IFC_FL"
    featureCapabilities = "Query"
    useCIMSymbols = False  # most compatabile
    sharingLevel = "OWNER"
    groups = "Flood Modeling - Working GP"
    offline = True
    offlineTarget = "ONLINE"
    overwriteExistingService = True

    try:
        aprx = arcpy.mp.ArcGISProject(aprx_path)
        map_obj = aprx.listMaps(map_name)[0]
        sddraft = map_obj.getWebLayerSharingDraft(server_type, service_type, service_name)

        # update sdraft parameter values
        sddraft.credits = credits
        sddraft.description = description
        sddraft.summary = summary
        sddraft.tags = tags
        sddraft.useLimitations = useLimitations
        sddraft.portalFolder = portalFolder
        sddraft.featureCapabilities = featureCapabilities
        sddraft.useCIMSymbols = useCIMSymbols
        sddraft.sharing.sharingLevel = sharingLevel
        sddraft.sharing.groups = groups
        sddraft.offlineTarget = offlineTarget
        sddraft.overwriteExistingService = overwriteExistingService
        sddraft.offline = offline

        # Export, Stage & Upload
        sddraft.exportToSDDraft(sddraft_path)
        arcpy.server.StageService(sddraft_path, sd_path)
        arcpy.server.UploadServiceDefinition(sd_path, server_type)

 

 

 

 

 

0 Kudos
0 Replies