Select to view content in your preferred language

UploadServiceDefinition gets the good old Error 999999.

1748
2
Jump to solution
11-29-2021 03:04 PM
Brian_Wilson
Honored Contributor

ExecuteError('ERROR 999999: Something unexpected caused the tool to fail. (etc etc)

Failed to execute (UploadServiceDefinition)

I am trying to publish a simple polygon feature layer to ArcGIS Enterprise 10.9.

The SD is created on the server but then the call throws the error before the service is created, so I end up with an SD in Portal but no feature service.

I'll  give you a snippet here...

from config import Config
import arcpy
arcpy.SignInToPortal(Config.PORTAL_URL, Config.PORTAL_USER, Config.PORTAL_PASSWORD)

project = arcpy.mp.ArcGISProject("K:/webmaps/basemap/basemap.aprx")
maps = project.listMaps()
mapnames = [map.name for map in maps]
map = maps[mapnames.index('Surveys')]
layer = map.listLayers()[0]

sd_name = "C:/TEMP/Surveys.sd"
sddraft_name = sd_name + "draft"
server_type = "HOSTING_SERVER"
service_name = 'Surveys'
sddraft = map.getWebLayerSharingDraft(server_type, "FEATURE", service_name, [layer])
sddraft.overwriteExistingService = True
sddraft.portalFolder = "Public Works"
sddraft.copyDataToServer = True
sddraft.exportToSDDraft(sddraft_name)

arcpy.env.overwriteOutput = True
arcpy.StageService_server(sddraft_name, sd_name)
arcpy.server.UploadServiceDefinition(sd_name, server_type)

 

This code executes in jupyter and gives this output

---------------------------------------------------------------------------
ExecuteError                              Traceback (most recent call last)
<ipython-input-15-7cf61cb19f9b> in <module>
      1 arcpy.env.overwriteOutput = True
      2 arcpy.StageService_server(sddraft_name, sd_name)
----> 3 result = arcpy.server.UploadServiceDefinition(sd_name, server_type)

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py in 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)
   1293         return retval
   1294     except Exception as e:
-> 1295         raise e
   1296 
   1297 

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py in 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)
   1290     from arcpy.arcobjects.arcobjectconversion import convertArcObjectToPythonObject
   1291     try:
-> 1292         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)))
   1293         return retval
   1294     except Exception as e:

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py in <lambda>(*args)
    510         val = getattr(self._gp, attr)
    511         if callable(val):
--> 512             return lambda *args: val(*gp_fixargs(args, True))
    513         else:
    514             return convertArcObjectToPythonObject(val)

ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Failed to execute (UploadServiceDefinition).

 

0 Kudos
1 Solution

Accepted Solutions
Brian_Wilson
Honored Contributor

To publish a MAP_IMAGE I have to change the server type to FEDERATED_SERVER, the service type to from FEATURE to MAP_IMAGE and add 

sddraft.federatedServerUrl = Config.SERVER_URL
 
and I can use either an AGS fiile or use the URL for in_server.
 
To publish a FEATURE service, I have to leave out the federatedServeUrl property in sddraft, 
change from "FEDERATED_SERVER" to "HOSTING_SERVER" for server_type and I have to use a reference to an AGS file for in_server (for example "in_server='K:/webmaps/server.ags'")
 
I can use the AGS file to publish the MAP_IMAGE but if I use the URL for FEATURE then it throws this
 
ExecuteError: ERROR 002901: Sharing related error during geo-processing (Unable to check if service exists. (Survey_Sample_FEATURES)) Failed to execute (UploadServiceDefinition).
 
For some reason the URL can't be used but the AGS file can... but for FEATURES, MAP_IMAGE is fine with either.
 
In all cases, when I view the results in Map Viewer it throws an error about a missing layer and then proceeds to load and display the layer. This is a separate problem though -- I can publish and republish now using an AGS file so I will pursue that path and see what's up with the missing layer, which does not show up in the properties for the services in Portal.
 
At least this works on the Thursday before Christmas. It might all be different next week! 
 

View solution in original post

2 Replies
Brian_Wilson
Honored Contributor

I tried using the "Publish" button on the SD page in Portal. That creates a broken feature service and an alery pops up with the "helpful" message "There was an error".  I'm not kidding, that's 100% of the error message.

I deleted that layer then tried using this code instead of UploadServiceDefinition

from arcgis.gis import GIS
gis = GIS(Config.PORTAL_URL, Config.PORTAL_USER, Config.PORTAL_PASSWORD)
sd = gis.content.add({}, sd_name)
sd.publish()

 

This code will quickly transfer the SD file in the add() call and works the same way the Publish button does -- creates a broken service. In this case the returned error message is "Exception: Job failed".

I am now assuming something in the set up of my .sddraft file is at fault. I tried stripping out the extra sddraft options (summary, tags, credits etc) but that had no impact.

 

0 Kudos
Brian_Wilson
Honored Contributor

To publish a MAP_IMAGE I have to change the server type to FEDERATED_SERVER, the service type to from FEATURE to MAP_IMAGE and add 

sddraft.federatedServerUrl = Config.SERVER_URL
 
and I can use either an AGS fiile or use the URL for in_server.
 
To publish a FEATURE service, I have to leave out the federatedServeUrl property in sddraft, 
change from "FEDERATED_SERVER" to "HOSTING_SERVER" for server_type and I have to use a reference to an AGS file for in_server (for example "in_server='K:/webmaps/server.ags'")
 
I can use the AGS file to publish the MAP_IMAGE but if I use the URL for FEATURE then it throws this
 
ExecuteError: ERROR 002901: Sharing related error during geo-processing (Unable to check if service exists. (Survey_Sample_FEATURES)) Failed to execute (UploadServiceDefinition).
 
For some reason the URL can't be used but the AGS file can... but for FEATURES, MAP_IMAGE is fine with either.
 
In all cases, when I view the results in Map Viewer it throws an error about a missing layer and then proceeds to load and display the layer. This is a separate problem though -- I can publish and republish now using an AGS file so I will pursue that path and see what's up with the missing layer, which does not show up in the properties for the services in Portal.
 
At least this works on the Thursday before Christmas. It might all be different next week!