<?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 exportToSDDraft Error connecting to server in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/exporttosddraft-error-connecting-to-server/m-p/1213673#M65630</link>
    <description>&lt;P&gt;I am trying to create an sddraft file for publishing a arcgis pro project to our portal.&lt;/P&gt;&lt;P&gt;Below is my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sddraft_filename = "service.sddraft"
sddraft_output_filename = os.path.join(draftsOutputDir, sddraft_filename)

service_draft = m.getWebLayerSharingDraft("FEDERATED_SERVER", "MAP_IMAGE" , service)

service_draft.summary = "My Summary"
service_draft.tags = "My Tags"
service_draft.description = "My Description"
service_draft.credits = "My Credits"
service_draft.useLimitations = "My Use Limitations"
service_draft.overwriteExistingService = True

service_draft.allowExporting = True
service_draft.portalFolder = "User_Folder"

service_draft.federatedServerUrl = "https://MyFederatedServer.esri.com:6443/arcgis"
service_draft.copyDataToServer = False
service_draft.serverFolder = "Server_Folder"


# Create Service Definition Draft file
service_draft.exportToSDDraft(sddraft_output_filename)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right when it execute the&amp;nbsp;&lt;SPAN&gt;exportToSDDraft function, its throwing the following error.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Message=Error connecting to server: https://MyFederatedServer.esri.com:6443/arcgis
Source=C:\Users\user\AppData\Local\Programs\ArcGIS\Pro\Resources\ArcPy\arcpy\sharing.py
StackTrace:
File "C:\Users\user\AppData\Local\Programs\ArcGIS\Pro\Resources\ArcPy\arcpy\sharing.py", line 68, in exportToSDDraft
    return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))
File "C:\Users\user\source\repos\PythonApplication1\PythonApplication1\PythonApplication1.py", line 118, in mapAndFeatureServicePublish
    service_draft.exportToSDDraft(sddraft_output_filename)
File "C:\Users\user\source\repos\PythonApplication1\PythonApplication1\PythonApplication1.py", line 162, in &amp;lt;module&amp;gt; (Current frame)
    mapAndFeatureServicePublish(m, draftsOutputDir, row, featureAccess = row['FEATURE ACCESS? (Y/N)'])&lt;/LI-CODE&gt;&lt;P&gt;The federated url is correct as I copied it from the portal admin and in the list of federated server url.&lt;/P&gt;&lt;P&gt;Also I am able to connect to via normal url and create connection to it also.&lt;/P&gt;&lt;P&gt;Kindly advise.&lt;/P&gt;</description>
    <pubDate>Sun, 18 Sep 2022 12:47:29 GMT</pubDate>
    <dc:creator>arahman_mdmajid</dc:creator>
    <dc:date>2022-09-18T12:47:29Z</dc:date>
    <item>
      <title>exportToSDDraft Error connecting to server</title>
      <link>https://community.esri.com/t5/python-questions/exporttosddraft-error-connecting-to-server/m-p/1213673#M65630</link>
      <description>&lt;P&gt;I am trying to create an sddraft file for publishing a arcgis pro project to our portal.&lt;/P&gt;&lt;P&gt;Below is my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sddraft_filename = "service.sddraft"
sddraft_output_filename = os.path.join(draftsOutputDir, sddraft_filename)

service_draft = m.getWebLayerSharingDraft("FEDERATED_SERVER", "MAP_IMAGE" , service)

service_draft.summary = "My Summary"
service_draft.tags = "My Tags"
service_draft.description = "My Description"
service_draft.credits = "My Credits"
service_draft.useLimitations = "My Use Limitations"
service_draft.overwriteExistingService = True

service_draft.allowExporting = True
service_draft.portalFolder = "User_Folder"

service_draft.federatedServerUrl = "https://MyFederatedServer.esri.com:6443/arcgis"
service_draft.copyDataToServer = False
service_draft.serverFolder = "Server_Folder"


# Create Service Definition Draft file
service_draft.exportToSDDraft(sddraft_output_filename)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right when it execute the&amp;nbsp;&lt;SPAN&gt;exportToSDDraft function, its throwing the following error.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Message=Error connecting to server: https://MyFederatedServer.esri.com:6443/arcgis
Source=C:\Users\user\AppData\Local\Programs\ArcGIS\Pro\Resources\ArcPy\arcpy\sharing.py
StackTrace:
File "C:\Users\user\AppData\Local\Programs\ArcGIS\Pro\Resources\ArcPy\arcpy\sharing.py", line 68, in exportToSDDraft
    return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft,self))
File "C:\Users\user\source\repos\PythonApplication1\PythonApplication1\PythonApplication1.py", line 118, in mapAndFeatureServicePublish
    service_draft.exportToSDDraft(sddraft_output_filename)
File "C:\Users\user\source\repos\PythonApplication1\PythonApplication1\PythonApplication1.py", line 162, in &amp;lt;module&amp;gt; (Current frame)
    mapAndFeatureServicePublish(m, draftsOutputDir, row, featureAccess = row['FEATURE ACCESS? (Y/N)'])&lt;/LI-CODE&gt;&lt;P&gt;The federated url is correct as I copied it from the portal admin and in the list of federated server url.&lt;/P&gt;&lt;P&gt;Also I am able to connect to via normal url and create connection to it also.&lt;/P&gt;&lt;P&gt;Kindly advise.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2022 12:47:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporttosddraft-error-connecting-to-server/m-p/1213673#M65630</guid>
      <dc:creator>arahman_mdmajid</dc:creator>
      <dc:date>2022-09-18T12:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: exportToSDDraft Error connecting to server</title>
      <link>https://community.esri.com/t5/python-questions/exporttosddraft-error-connecting-to-server/m-p/1214541#M65649</link>
      <description>&lt;P&gt;If your server is set with an admin login for port 6443, it could be failing on not getting a login token.&amp;nbsp; Try using the server connection file (ends with .ags) for the connection instead of the url.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, you will have to generate a token and pass it with your url.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;service_url = f"https://MyFederatedServer.esri.com:6443/arcgis/services/.../...?token={token}&amp;amp;f=json"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 12:01:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporttosddraft-error-connecting-to-server/m-p/1214541#M65649</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-09-21T12:01:20Z</dc:date>
    </item>
  </channel>
</rss>

