<?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 Re: ArcMap needs to be open to make UploadServiceDefinition_server run in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcmap-needs-to-be-open-to-make/m-p/753741#M36998</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You only need Python 3.5 for the API.&amp;nbsp; Here are instructions on how to set it up:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/python/guide/install-and-set-up/" title="https://developers.arcgis.com/python/guide/install-and-set-up/"&gt;install and set up | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Dec 2017 13:49:17 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2017-12-04T13:49:17Z</dc:date>
    <item>
      <title>ArcMap needs to be open to make UploadServiceDefinition_server run</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcmap-needs-to-be-open-to-make/m-p/753738#M36995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV class=""&gt;&lt;P&gt;I have the following Python snippet to run to publish a MXD to ArcGIS Online My Content. I am with ArcGIS 10.1. The sddraft and sd files were both correctly generated.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;
import sys, os
import shutil
import arcpy, arcgisscripting


sddraft = 'DIR'
sd = 'DIR'

# delete the sd file if it already exists; otherwise pass
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; os.remove(sd)
except OSError:
&amp;nbsp;&amp;nbsp;&amp;nbsp; pass

# if required, sign in to My Hosted Services
print "SignInToPortal_server"
&lt;SPAN&gt;print arcpy.SignInToPortal_server("MYNAME", "PASSWORD", "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.arcgis.com%2F" target="_blank"&gt;http://www.arcgis.com/&lt;/A&gt;&lt;SPAN&gt;")&lt;/SPAN&gt;

# create service definition
print "StageService_server"
print arcpy.StageService_server(sddraft, sd)



# publish to My Hosted Services, replacement already allowed as it has been defined in the sddraft file!
print "UploadServiceDefinition_server"
arcpy.UploadServiceDefinition_server(sd, "My Hosted Services", service, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "", "FROM_SERVICE_DEFINITION", "EXISTING", 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "STARTED", "OVERRIDE_DEFINITION", "SHARE_ONLINE", 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "PUBLIC", "SHARE_ORGANIZATION", "")

# Sign out from ArcGIS Online
arcpy.SignOutFromPortal_server()
&lt;BR class="" /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I ran the script with ArcMap opened, it worked well. However, if I closed ArcMap and ran it, it threw the following error:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;
Traceback (most recent call last):
&amp;nbsp; File "PubToAGOL_Test.py", line 38, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; "PUBLIC", "SHARE_ORGANIZATION", "")
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\server.py", line 1
255, in UploadServiceDefinition
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Server: Dataset My Hosted Services does not exist or is not suppor
ted
Failed to execute (UploadServiceDefinition).&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The same error was thrown even if I left out all the optional params like below&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;UploadServiceDefinition_server&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;sd&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;"My Hosted Services"&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:59:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcmap-needs-to-be-open-to-make/m-p/753738#M36995</guid>
      <dc:creator>AlexChen</dc:creator>
      <dc:date>2021-12-12T07:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap needs to be open to make UploadServiceDefinition_server run</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcmap-needs-to-be-open-to-make/m-p/753739#M36996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alex,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a known issue, that I believe broke at 10.2.&amp;nbsp; When uploading the SD to ArcGIS Online, it will piggy back off of ArcGIS Desktop's connection.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a workaround you leverage the new &lt;A href="https://developers.arcgis.com/python/"&gt;ArcGIS API for Python&lt;/A&gt; to publish the SD file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/python/sample-notebooks/publishing-sd-shapefiles-and-csv/" title="https://developers.arcgis.com/python/sample-notebooks/publishing-sd-shapefiles-and-csv/"&gt;Publishing SDs shapefiles and CSVs | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Dec 2017 13:23:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcmap-needs-to-be-open-to-make/m-p/753739#M36996</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2017-12-04T13:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap needs to be open to make UploadServiceDefinition_server run</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcmap-needs-to-be-open-to-make/m-p/753740#M36997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jake! Does the new ArcGIS API for Python work with ArcGIS 10.1 that I have to stick with?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Dec 2017 13:45:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcmap-needs-to-be-open-to-make/m-p/753740#M36997</guid>
      <dc:creator>AlexChen</dc:creator>
      <dc:date>2017-12-04T13:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap needs to be open to make UploadServiceDefinition_server run</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcmap-needs-to-be-open-to-make/m-p/753741#M36998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You only need Python 3.5 for the API.&amp;nbsp; Here are instructions on how to set it up:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/python/guide/install-and-set-up/" title="https://developers.arcgis.com/python/guide/install-and-set-up/"&gt;install and set up | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Dec 2017 13:49:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcmap-needs-to-be-open-to-make/m-p/753741#M36998</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2017-12-04T13:49:17Z</dc:date>
    </item>
  </channel>
</rss>

