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?