Python script unable to find target server

436
2
07-03-2023 07:53 AM
RVx_GaslineGiS
New Contributor III

I'm trying to overwrite a published service on a federated server. I've been following the ESRI sample script here: https://github.com/jnshill/ArcPyPublishing/blob/8af7523a692498e4c22a142dfc940e3c355efaba/PublishLaye... without much success.

Despite assigning the federatedServerURL, I get a "Missing target server" error. I've confirmed that the token I pull from the Portal works by singing into the REST API. I verified the federated server URL by logging into the Portal Administrator Directory -> Federation -> Servers and snagging the URL field from there.

However, even with all of that....still missing target server. In the python code, I can call the .federatedServerURL and it will yield a result that matches with what is in my administrator directory.

 

Anyone have any ideas on what else to check?

   outdir = r'D:\\location'
   ## Folder the Map Service will Go too
   in_folder="Folder1"
   service = "servicename"
   sddraft_filename = service + ".sddraft"
   sddraft_output_filename = os.path.join(outdir, sddraft_filename)

   # Reference map to publish
   aprx = arcpy.mp.ArcGISProject(r"C:\\Project.aprx")
   # Get first map
   m = aprx.listMaps("MapName")[0]
   # List enterprise URl and credentials here
   portalURL = r"https://portalServer/webAdaptor"
   fed_server = r"https://ServerURL/webAdaptor"
   cred_detail = []
   #sign into credentials
   portal_pw = keyring.get_password("stuff", "user")
   portal_user = "user"
   #Sign into Portal
   arcpy.SignInToPortal(portalURL, portal_user, portal_pw)
   
   # Create MapImageSharingDraft and set service properties
   sharing_draft = m.getWebLayerSharingDraft("FEDERATED_SERVER", "MAP_IMAGE", service)
   sharing_draft.federatedServerURL = fed_server
   sharing_draft.portalFolder = 'Folder1'
   sharing_draft.description = "Description"
   sharing_draft.credits = "Name"
   sharing_draft.tags = "Tags"
   sharing_draft.copyDataToServer = False
   sharing_draft.overwriteExistingService = True
   sharing_draft.exportToSDDraft(sddraft_output_filename)
0 Kudos
2 Replies
StaticK
MVP

That url advice in the documentation is maybe right for some, but for us we had to use the https://domain/arcgis url.  using /webadapter as suggested fails.

However, my script gets up to the stage service and the bombs with 999999.

0 Kudos
Tejwant
New Contributor

Hi @RVx_GaslineGiS ,

Were you able to resolve this issue?

 

0 Kudos