<?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 arcpy.server.StageService works in Pro but fails in VSC, propy, proenv with ERROR 999999 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-server-stageservice-works-in-pro-but-fails/m-p/1342481#M69053</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I am trying to automate the publishing of map services, and am having issues with the function&amp;nbsp;arcpy.StageService_server.&amp;nbsp;The code works when executed within the python window in ArcGIS Pro 3.x but fails in propy, proenv and visual studio code while using the library in arcgispro-py3.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DerrickWong_0-1698375762018.png" style="width: 974px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84232iB50F2E328F1CF39E/image-dimensions/974x185?v=v2" width="974" height="185" role="button" title="DerrickWong_0-1698375762018.png" alt="DerrickWong_0-1698375762018.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;This is for a ArcGIS Server 10.9.1 which is unfederated.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I have also tested this on another 10.9.1 federated enterprise, as well as 11.1&amp;nbsp;using getWebLayerSharingDraft&amp;nbsp;function and am able to reproduce the error.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sd = mp.getWebLayerSharingDraft('FEDERATED_SERVER', 'MAP_IMAGE', servicename)
sd.federatedServerUrl = self.server_url&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;For Standalone, I am using:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sd = arcpy.sharing.CreateSharingDraft('STANDALONE_SERVER', 'MAP_SERVICE', 'test', mp)
sd.targetServer = '\\\\Server1234\\automate\\agsconnection\\agsconnection.ags'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I have tried exporting the python script from pro and executing it returns the same result as well.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DerrickWong_1-1698376886523.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84233i67D76A6CBBD093EB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DerrickWong_1-1698376886523.png" alt="DerrickWong_1-1698376886523.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Sample code I am trying to run:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

arcpy.server.StageService(r"C:\Work\Projects\Web Service Automation\sddrafts\test.sddraft", r"C:\Work\Projects\Web Service Automation\sds\test.sd", None)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tested using double slashes ("C:\\Work\\..."), back slashes, as well as a shared network path (r"\\server\automate\..."&amp;nbsp; and "\\\\server\\automate\\..) with full control.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I have added a breakpoint and it's throwing an error on the function convertArcObjectToPythonObject in server.py line at 1167:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DerrickWong_2-1698377000034.png" style="width: 772px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84234i3253EBCCC3A310D5/image-dimensions/772x149?v=v2" width="772" height="149" role="button" title="DerrickWong_2-1698377000034.png" alt="DerrickWong_2-1698377000034.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;IIS, Server, Portal, DS have all been registered with a CA-Signed SSL Certificate.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I have also tried adding the following line:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ssl._create_default_https_context = ssl._create_unverified_context&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;For some more context, I have no issues executing the GIS module on a federated server in VSC. I am able to sign in, create/delete items, etc.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Does anyone know why ArcGIS Pro handles this differently from VSCode?&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Cheers,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Derrick&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2023 03:49:52 GMT</pubDate>
    <dc:creator>DerrickWong</dc:creator>
    <dc:date>2023-10-27T03:49:52Z</dc:date>
    <item>
      <title>arcpy.server.StageService works in Pro but fails in VSC, propy, proenv with ERROR 999999</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-server-stageservice-works-in-pro-but-fails/m-p/1342481#M69053</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I am trying to automate the publishing of map services, and am having issues with the function&amp;nbsp;arcpy.StageService_server.&amp;nbsp;The code works when executed within the python window in ArcGIS Pro 3.x but fails in propy, proenv and visual studio code while using the library in arcgispro-py3.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DerrickWong_0-1698375762018.png" style="width: 974px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84232iB50F2E328F1CF39E/image-dimensions/974x185?v=v2" width="974" height="185" role="button" title="DerrickWong_0-1698375762018.png" alt="DerrickWong_0-1698375762018.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;This is for a ArcGIS Server 10.9.1 which is unfederated.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I have also tested this on another 10.9.1 federated enterprise, as well as 11.1&amp;nbsp;using getWebLayerSharingDraft&amp;nbsp;function and am able to reproduce the error.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sd = mp.getWebLayerSharingDraft('FEDERATED_SERVER', 'MAP_IMAGE', servicename)
sd.federatedServerUrl = self.server_url&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;For Standalone, I am using:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sd = arcpy.sharing.CreateSharingDraft('STANDALONE_SERVER', 'MAP_SERVICE', 'test', mp)
sd.targetServer = '\\\\Server1234\\automate\\agsconnection\\agsconnection.ags'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I have tried exporting the python script from pro and executing it returns the same result as well.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DerrickWong_1-1698376886523.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84233i67D76A6CBBD093EB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DerrickWong_1-1698376886523.png" alt="DerrickWong_1-1698376886523.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Sample code I am trying to run:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

arcpy.server.StageService(r"C:\Work\Projects\Web Service Automation\sddrafts\test.sddraft", r"C:\Work\Projects\Web Service Automation\sds\test.sd", None)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tested using double slashes ("C:\\Work\\..."), back slashes, as well as a shared network path (r"\\server\automate\..."&amp;nbsp; and "\\\\server\\automate\\..) with full control.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I have added a breakpoint and it's throwing an error on the function convertArcObjectToPythonObject in server.py line at 1167:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DerrickWong_2-1698377000034.png" style="width: 772px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84234i3253EBCCC3A310D5/image-dimensions/772x149?v=v2" width="772" height="149" role="button" title="DerrickWong_2-1698377000034.png" alt="DerrickWong_2-1698377000034.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;IIS, Server, Portal, DS have all been registered with a CA-Signed SSL Certificate.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I have also tried adding the following line:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ssl._create_default_https_context = ssl._create_unverified_context&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;For some more context, I have no issues executing the GIS module on a federated server in VSC. I am able to sign in, create/delete items, etc.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Does anyone know why ArcGIS Pro handles this differently from VSCode?&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Cheers,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Derrick&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 03:49:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-server-stageservice-works-in-pro-but-fails/m-p/1342481#M69053</guid>
      <dc:creator>DerrickWong</dc:creator>
      <dc:date>2023-10-27T03:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.server.StageService works in Pro but fails in VSC, propy, proenv with ERROR 999999</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-server-stageservice-works-in-pro-but-fails/m-p/1345881#M69154</link>
      <description>&lt;P&gt;I am in the same boat. The programmatic process to create these services and requirements of editing the xml to change properties introduces a lot places for errors and is terrible. All you get back from the method is 999999.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adding a FeatureService should be as easy as sddraft.FeatureService = True but instead the process is 4-5 for/if statements to drill down and find the right Node and add/ change the setting. Same with setting the editing, uploads, etc.,. capabilities-&amp;nbsp; Why can't the method generate these properties in the xml? sddraft.FeatureService.Capabilities = 'Query,Sync,Editing'&amp;nbsp; It's ugly...&lt;/P&gt;&lt;P&gt;There could be so many things that cause error too- Are you signing into the server/ portal in your code?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis = GIS('Pro')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2023 14:21:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-server-stageservice-works-in-pro-but-fails/m-p/1345881#M69154</guid>
      <dc:creator>StaticK</dc:creator>
      <dc:date>2023-11-04T14:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.server.StageService works in Pro but fails in VSC, propy, proenv with ERROR 999999</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-server-stageservice-works-in-pro-but-fails/m-p/1346481#M69172</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/458555"&gt;@StaticK&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply. Yeah getting a 999999 isn't ideal and doesn't narrow down what the issue is. It's pretty much trial and error to try to isolate the issue at the moment and we are not having much fun with it.&lt;/P&gt;&lt;P&gt;On the federated server, we did use&amp;nbsp;&lt;EM&gt;gis&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;GIS&lt;/EM&gt;&lt;SPAN&gt;(&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;verify_cert&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;False&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;....) but it still errors out anywhere outside of Pro.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Derrick&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 01:36:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-server-stageservice-works-in-pro-but-fails/m-p/1346481#M69172</guid>
      <dc:creator>DerrickWong</dc:creator>
      <dc:date>2023-11-07T01:36:47Z</dc:date>
    </item>
  </channel>
</rss>

