<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic UploadServiceDefinition gets the good old Error 999999. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/uploadservicedefinition-gets-the-good-old-error/m-p/1121071#M63095</link>
    <description>&lt;P&gt;ExecuteError('ERROR 999999: Something unexpected caused the tool to fail. (etc etc)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Failed to execute (UploadServiceDefinition)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am trying to publish a simple polygon feature layer to ArcGIS Enterprise 10.9.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;I'll&amp;nbsp; give you a snippet here...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code executes in jupyter and gives this output&lt;/P&gt;&lt;LI-CODE lang="python"&gt;---------------------------------------------------------------------------
ExecuteError                              Traceback (most recent call last)
&amp;lt;ipython-input-15-7cf61cb19f9b&amp;gt; in &amp;lt;module&amp;gt;
      1 arcpy.env.overwriteOutput = True
      2 arcpy.StageService_server(sddraft_name, sd_name)
----&amp;gt; 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:
-&amp;gt; 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:
-&amp;gt; 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 &amp;lt;lambda&amp;gt;(*args)
    510         val = getattr(self._gp, attr)
    511         if callable(val):
--&amp;gt; 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).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Nov 2021 23:04:40 GMT</pubDate>
    <dc:creator>Brian_Wilson</dc:creator>
    <dc:date>2021-11-29T23:04:40Z</dc:date>
    <item>
      <title>UploadServiceDefinition gets the good old Error 999999.</title>
      <link>https://community.esri.com/t5/python-questions/uploadservicedefinition-gets-the-good-old-error/m-p/1121071#M63095</link>
      <description>&lt;P&gt;ExecuteError('ERROR 999999: Something unexpected caused the tool to fail. (etc etc)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Failed to execute (UploadServiceDefinition)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am trying to publish a simple polygon feature layer to ArcGIS Enterprise 10.9.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;I'll&amp;nbsp; give you a snippet here...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code executes in jupyter and gives this output&lt;/P&gt;&lt;LI-CODE lang="python"&gt;---------------------------------------------------------------------------
ExecuteError                              Traceback (most recent call last)
&amp;lt;ipython-input-15-7cf61cb19f9b&amp;gt; in &amp;lt;module&amp;gt;
      1 arcpy.env.overwriteOutput = True
      2 arcpy.StageService_server(sddraft_name, sd_name)
----&amp;gt; 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:
-&amp;gt; 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:
-&amp;gt; 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 &amp;lt;lambda&amp;gt;(*args)
    510         val = getattr(self._gp, attr)
    511         if callable(val):
--&amp;gt; 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).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 23:04:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploadservicedefinition-gets-the-good-old-error/m-p/1121071#M63095</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2021-11-29T23:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: UploadServiceDefinition gets the good old Error 999999.</title>
      <link>https://community.esri.com/t5/python-questions/uploadservicedefinition-gets-the-good-old-error/m-p/1121091#M63097</link>
      <description>&lt;P&gt;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".&amp;nbsp; I'm not kidding, that's 100% of the error message.&lt;/P&gt;&lt;P&gt;I deleted that layer then tried using this code instead of UploadServiceDefinition&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.gis import GIS
gis = GIS(Config.PORTAL_URL, Config.PORTAL_USER, Config.PORTAL_PASSWORD)
sd = gis.content.add({}, sd_name)
sd.publish()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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".&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 00:37:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploadservicedefinition-gets-the-good-old-error/m-p/1121091#M63097</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2021-11-30T00:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: UploadServiceDefinition gets the good old Error 999999.</title>
      <link>https://community.esri.com/t5/python-questions/uploadservicedefinition-gets-the-good-old-error/m-p/1128518#M63326</link>
      <description>&lt;P&gt;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&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sddraft&lt;/SPAN&gt;&lt;SPAN&gt;.federatedServerUrl = &lt;/SPAN&gt;&lt;SPAN&gt;Config&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SERVER_URL&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and I can use either an AGS fiile or use the URL for in_server.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;To publish a FEATURE service, I have to leave out the federatedServeUrl property in sddraft,&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;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'")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I can use the AGS file to publish the MAP_IMAGE but if I use the URL for FEATURE then it throws this&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;STRONG&gt;ExecuteError&lt;/STRONG&gt;: ERROR 002901: Sharing related error during geo-processing (Unable to check if service exists. (Survey_Sample_FEATURES)) Failed to execute (UploadServiceDefinition).&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;For some reason the URL can't be used but the AGS file can... but for FEATURES, MAP_IMAGE is fine with either.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;At least this works on the Thursday before Christmas. It might all be different next week!&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Dec 2021 18:14:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploadservicedefinition-gets-the-good-old-error/m-p/1128518#M63326</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2021-12-23T18:14:56Z</dc:date>
    </item>
  </channel>
</rss>

