0

I am using Esri's guidance for arcpy.UploadServiceDefinition_server (http://desktop.arcgis.com/en/arcmap/10.6/tools/server-toolbox/upload-service-definition.htm)

I can successfully upload a service definition to my organisation's ArcGIS Online. However it always only appears in my root content folder and it is not shared with the group I have specified. My code is below. I have tried this in both Python 2.7 (ArcMap 10.6) and Python 3 (ArcGIS Pro 2.3) and get the same results.

import arcpy
arcpy.env.workspace = "C:/arcgis"

# Set local variables
inSdFile = "Data_Test.sd"
inServer = "My Hosted Services"
serviceName = "Feature_Data"
in_folder = "Habitat management"
in_group = "Habitats Group"

# Execute UploadServiceDefinition
arcpy.UploadServiceDefinition_server(inSdFile, "My Hosted Services", serviceName, "", "EXISTING", in_folder, "", "OVERRIDE_DEFINITION", "SHARE_ONLINE", "PRIVATE", "NO_SHARE_ORGANIZATION", in_group)

print ("Uploaded service")

I have checked and triple checked the names of the group and the folder, capitals/lowercase, and both are definitely correct.

I found this reported bug for Pro: https://community.esri.com/thread/228929-arcgis-pro-23-sharing-module-error But nothing to suggest the ArcMap version wouldn't work.

I'm really not keen on having to learn Jupyter Notebooks/the ArcGIS API for Python just now. I'm only just getting to grips with ArcPy!

Does anyone have any other suggestions on how I can work around this? Is there a way to update the group in ArcPy after service definition upload?

0

The UploadServiceDefinition tool was originally created to publish services to ArcGIS Server. The ArcGIS/Esri stack has evolved that publishing is now done to a portal (portal and ArcGIS Online are essentially the same thing for the sake of this answer). The in_folder parameter on the tool was used to set the folder for the GIS Server originally. I'd bet that it's still set and used to share only to the Server folder. So when you're publishing to ArcGIS Online, you don't actually see the back end server, you only see the item created in portal and it's not getting place into a portal folder. In short, the UploadServiceDefinition in_folder parameter is not going to put it into portal folder.

Go look at the ArcGIS Pro publishing UI when publishing to your Enterprise (Portal + GIS Server), you'll see there are 2 options; a server folder and a portal folder.

What can you do? If you're using ArcGIS Pro you can look at the FeatureSharingDraft function. This function allows you to bake a portal folder into the draft using the portalFolder parameter. Then I'd suspect after using the UploadServiceDefinition tool, you'll see your item created in the folder on ArcGIS Online.

Note: This answer is based on knowledge and assumptions that might be out of date. I'd be happy to be proved wrong by another answer.

  • Thank you, that makes sense (although wish it was clearer in the Arc guidance!). The portalFolder parameter works to put the item in the correct folder, which is great. However sharing it with a specific group is really the most important part of the process. Is that possible? I couldn't see anything in the FeatureSharingDraft function that would allow this. – earthwriter Aug 16 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.