Select to view content in your preferred language

sddraft parameter 'PackageIsPublic' set to 'true' doesn't publish my sd as PUBLIC

03-15-2023 07:22 AM
Labels (3)
New Contributor III


I'm using arcgis api to publish services to different ArcGIS environnements. 

This particular case involves a 'Map Image Layer' being published as 'PUBLIC' into the 'HOSTING_SERVER' of my portal.

I obtain my server by listing the servers in my GIS using GIS.admin.servers.list() and then selecting the correct one that matches the name I'm after.

I am creating an sddraft using the method getWebLayerSharingDraft()

I then open the sddraft XML and enrich it with data from another source. 

Before stageing my sddraft (creating an sd from the sddraft) I replace the value of the key 'PackageIsPublic' to 'true' (no caps & as string) and 'PackageUnderMyContent''PackageUnderMyOrg''PackageShareGroups' to 'false'.

When I publish with or with server.publish_sd() : in my portal it shows as private. 

I looked into arcpy.server.UploadServiceDefinition() and also the service_config=None parameter from plublish_sd() but neither worked or gave me back comprehensible error messages.

Q: Why do the values of my sddraft not transfer over to my item when I publish it? Am I missing an argument from arcpy.server.StageService() 

Q: What are the values that CAN go inside the service_config=None parameter from publish_sd?! This information I could not find anywhere!

Q: Am I going at it wrong and should be using item.add() and upload(sd) given that I'm publishing onto Portal + rest?

thanks for getting this far hehe

0 Kudos
2 Replies
Esri Contributor

Hi @NicolasRojas Thanks for reporting this issue. In theory, if you use arcpy to create the sddraft and stage as sd file, the ideal workflow is to do use arcpy again to upload the sd file with the sharing options set in the parameters.

With ArcGIS API for Python, we have our own set of APIs to upload and customize the sd file, which are not exposed to users currently. In order to use `publish_sd` method with the customized `service_config` parameter, you might need to perform the equivalent workflow with Python APIs again as to retrieve the `service_config`.

Do you mind sharing about your organization and why you chose to use this workflow? esp. the reason why use arcpy first and then Python API after uploading? This could help us decide if we need to expose the internal methods. Thanks!

New Contributor III

Hello @cpeng_esri Thanks for your reply.

I see.

I'm using a mix of both the python API and arcpy because:

  1. We are publishing services start as maps in ArcGIS pro. Once we have the sd file, we drop arcpy and use the API
  2. Our client would like some flexibility as to where they publish services with varying access (yes, it's quite broad).ie private portal map image service with groups, public standalone non federated map service or  public standalone non federated map service with OGC capabilities.

I resolved the question by fetching the service after publication and changeing the access (private, org, everyone) with the python API function service.share(everyone=True, org=False, groups=[groups_ids]).

This approach isn't fit for standalone non fed. services so I used the requests python library to send push requests to the permission/add endpoint in order to update service permissions and groups. I needed to generate a token and login as admin in order to make it work for stopped or private services.

I hope this clears up your question. I'm curious about the internal API methods you mentioned. Can you talk a little more about them? Are they under developpment at the moment or they simply didn't make the cut to the users?


0 Kudos