Use of parameters in UploadServiceDefinition_server tool on ArcGIS Online with ArcPy

12-03-2017 05:02 PM
New Contributor III

I would need to automate publishing my mxd to ArcGIS Online as a publicly-accessible feature service. So it will be shared by everyone. I am with ArcGIS 10.1 so I cannot use the MXDToWebMap_server tool as it is only available to ArcGIS 10.3 and above.

I am able to get most of the automation done by following the help document:

ArcGIS Help 10.1  to run the following tools in the correct order

  1. arcpy.mapping.CreateMapSDDraft
  2. Update sddraft file to allow replacement (overwriting the published feature service if already existing)
  3. arcpy.StageService_server
  4. arcpy.SignInToPortal_server
  5. arcpy.UploadServiceDefinition_server

The problem I came across is, the feature service is replaced and the Share properties are changed to prvivate even if I manually set up Shared with Everyone.

The help document does not specify whether and how we can set up the Share properties in the sd file before uploading.

I did find there are a whole bunch of parameters for the arcpy.UploadServiceDefinition_server tool:

UploadServiceDefinition_server (in_sd_file, in_server, {in_service_name}, {in_cluster}, {in_folder_type}, {in_folder}, {in_startupType}, {in_override}, {in_my_contents}, {in_public}, {in_organization}, {in_groups})

I am assuming the {in_public} param is the one I need to use. But I would prefer a working example of use of those parameters in the context of publishing to ArcGIS Online (i.e. 'My Hosted Services').

5 Replies
Occasional Contributor

Did you ever find a solution to your problem? I'm having the same issue. I'd love to see an example of someone using the `in_public` parameter successfully.

Occasional Contributor III

I'm using: 


This still sets my service to private.

0 Kudos
Occasional Contributor III

I was having same issue.

Trying to schedule overwriting a service on ArcGIS Online, script being triggered from a machine running ArcGIS Pro 2.3

The following works for me.

Make sure you include the in_override parameter.

arcpy.UploadServiceDefinition_server(sd_output_filename, "My Hosted Services", in_override="OVERRIDE_DEFINITION", in_public="PUBLIC")‍‍
Occasional Contributor

Thank you, I have no idea why this works but it does

0 Kudos
New Contributor III

Thanks it works, I had the same problem with arcgis pro 2.6.0 and portal 10.7

0 Kudos