ArcGIS Pro 2.3 using Arcpy UploadServiceDefinition_server, service publishes in root but not a folder

2642
8
07-12-2019 08:55 AM
EricaPfister
New Contributor III

I'm publishing a map service from ArcGIS Pro 2.3 using a Python script. It gets through create a service draft and staging the service with no errors. When uploading the service definition, it succeeds when publishing to the root folder:

arcpy.UploadServiceDefinition_server(sd, arcgis_server)

It fails if I try to publish to a different folder, either creating a new one or using an existing one (made in Server Manager):

arcpy.UploadServiceDefinition_server(sd, arcgis_server, in_folder_type="NEW", in_folder="test_pro")

or

arcpy.UploadServiceDefinition_server(sd, arcgis_server, in_folder_type="EXISTING", in_folder="test_pro")

Each of these fail with an error along the lines of:

Traceback (most recent call last):   File "", line 1, in    File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\server.py", line 991, in UploadServiceDefinition     raise e   File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\server.py", line 988, in UploadServiceDefinition     retval = convertArcObjectToPythonObject(gp.UploadServiceDefinition_server(*gp_fixargs((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), True)))   File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 498, in      return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 001369: Failed to create the service. Failed to execute (Publish Service Definition). Failed. Failed to execute (UploadServiceDefinition).

While I can work with publishing to root for testing purposes, it's not going to be acceptable for production level automation -- our services get organized into a number of directories and never stay in the root. What is causing UploadServiceDefinition_server to fail when I try to specify a target folder as a parameter?

8 Replies
ThomasColson
MVP Frequent Contributor

Try a folder without "_" in the name....

0 Kudos
EricaPfister
New Contributor III

Good thought, but same error with folder "test", unfortunately.

0 Kudos
EricaPfister
New Contributor III

More curious, if I try a folder that doesn't exist:

arcpy.UploadServiceDefinition_server(sd, arcgis_server, in_folder_type="EXISTING", in_folder="notafolder")

it uploads successfully, without comment, to the root -- doesn't create notafolder, and doesn't warn me about the different destination.

0 Kudos
ThomasColson
MVP Frequent Contributor

I think you're in tech support territory with this

Arne_Gelfert
Occasional Contributor III

Glad to hear I'm not the only one. Thought I might be doing something wrong. Same behavior. I wanted to publish to a folder besides root and tried.

inSdFile = sd_output_filename
inServer = myserver
inFolderType = 'EXISTING'
inFolder = 'Test'

arcpy.UploadServiceDefinition_server(inSdFile, inServer, inFolderType, inFolder)

Well that fails miserably...

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000800: The value is not a member of default.
Failed to execute (UploadServiceDefinition).

Leaving out all the parameters except for sdfile and server, works fine. So connection is working.

Similarly, trying to create a new folder bombs with the same error.

inSdFile = sd_output_filename
inServer = myserver
inFolderType = 'NEW'
inFolder = 'Test2'

This is from arcpy.UploadServiceDefinition_server.__doc__

in_folder_type {String}:

The folder type used to determine the source for the folder. The default is to get a folder from the service definition. You can also choose to get a list of folders already existing on the specified online server, or you can specify a new folder to be created once you share this web layer.

* NEW-Creates a new folder.

* EXISTING-Specifies a folder that exists on the server.

* FROM_SERVICE_DEFINITION-The folder already specified in the service definition. This is the default.

in_folder {String}:

Use this option to specify the folder for the web layer. The default is to use the folder specified in the service definition. If you chose New folder type, use this parameter to enter a new folder name. If you chose Existing folder type, you can choose from the existing folders on the server.

There are some references to Error 00800, but nothing that helped with this:

Description

The keyword used is not a member of the list of acceptable keywords.

Solution

Change the keyword to a member of the list provided. For more information on what each keyword signifies, review the tool's help.

I'm thinking this somehow is a bug. Interestingly the ESRI online documentation even's got the name of the method wrong, which mirrors the Error message above. Maybe the used the wrong keywords in there somewhere.

Upload Service Definition—Help | ArcGIS Desktop

UploadServiceDefinition(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})

EricaPfister
New Contributor III

Turns out it is a recognized bug that I was running into (and you as well it appears) -- according to https://my.esri.com/#/support/bugs/BUG-000118315 it will be fixed in Pro 2.5.

Arne_Gelfert
Occasional Contributor III

Well, thanks for confirming. The link didn't work for me, I think because it's your "myesri". But that's ok. At least, I can focus on finding a usable workaround.

JamesSaunders
New Contributor II

Just to clarify for anyone who is having this problem, it is a real bug (see link here), but there is a good way to get around it.  When creating the FeatureSharingDraft object before the upload (as outlined here), simply add one more line (see bold below)

# Create FeatureSharingDraft and set service properties sharing_draft = m.getWebLayerSharingDraft("HOSTING_SERVER", "FEATURE", service)

sharing_draft.summary = "My Summary"

sharing_draft.tags = "My Tags"

sharing_draft.description = "My Description"

sharing_draft.credits = "My Credits"

sharing_draft.useLimitations = "My Use Limitations"

sharing_draft.portalFolder = "Test Folder"

Where "Test Folder" is the name of the folder on your server where you want to do the upload.  Then when you call the arcpy.UploadServiceDefinition_server function, and set the in_folder_type="EXISTING", it will look to the portal folder you specified in your FeatureSharingDraft object. Hope that helps!