exportToSDDraft Error connecting to server

1014
1
09-18-2022 05:47 AM
arahman_mdmajid
Occasional Contributor

I am trying to create an sddraft file for publishing a arcgis pro project to our portal.

Below is my code.

 

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)

 

Right when it execute the exportToSDDraft function, its throwing the following error.

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 <module> (Current frame)
    mapAndFeatureServicePublish(m, draftsOutputDir, row, featureAccess = row['FEATURE ACCESS? (Y/N)'])

The federated url is correct as I copied it from the portal admin and in the list of federated server url.

Also I am able to connect to via normal url and create connection to it also.

Kindly advise.

Abdur Rahman
GIS Developer
0 Kudos
1 Reply
by Anonymous User
Not applicable

If your server is set with an admin login for port 6443, it could be failing on not getting a login token.  Try using the server connection file (ends with .ags) for the connection instead of the url.

target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"

 

Or, you will have to generate a token and pass it with your url.

service_url = f"https://MyFederatedServer.esri.com:6443/arcgis/services/.../...?token={token}&f=json"

 

0 Kudos