Select to view content in your preferred language

Geoprocessing task fails to access Living Atlas layer

611
2
Jump to solution
09-22-2024 09:06 AM
DonMorrison1
Frequent Contributor

I've found that when I run a python toolbox tool as a geoprocessing task on our ArcGIS server (11.3.0), it fails when I try to access a public layer from the ESRI living atlas (https://landscape10.arcgis.com/arcgis/rest/services/USA_NLCD_Land_Cover/ImageServer) with this message:

esriJobMessageTypeError: Traceback (most recent call last): File "<string>", line 58, in execute File "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\Resources\ArcPy\arcpy\__init__.py", line 1335, in Describe return gp.describe(value, data_type) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 384, in describe self._gp.Describe(*gp_fixargs(args, True))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: "https://landscape10.arcgis.com/arcgis/rest/services/USA_NLCD_Land_Cover/ImageServer" does not exist

It doesn't appear to be a connectivity problem.  I works when run from my client. Is there a server configuration option preventing this sort of connection?

    def execute(self, parameters, messages):
        import requests
        url = 'https://landscape10.arcgis.com/arcgis/rest/services/USA_NLCD_Land_Cover/ImageServer'
        arcpy.AddMessage("Status code: " + str(requests.head(url).status_code)) # Prints 302 (redirect)
        arcpy.Describe(url)
        return

  

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DonMorrison1
Frequent Contributor

According to ESRI support:  

Unfortunately, it does seem that accessing protected URLs directly via arcpy within a geoprocessing task is not feasible due to how the arcpy library handles security for such resources. Using REST APIs with a token-based authentication is a reliable alternative.

View solution in original post

0 Kudos
2 Replies
DonMorrison1
Frequent Contributor

I made some progress on this in that I believe the problem is that that particular image service requires "subscriber" status which I think simply means the user has to be logged in so a token gets sent along with the request. When I log out of ArcGIS Pro and run the tool it fails that same way as when it is run on the server. I'm still at a loss as to how to do this login on the server where the geoprocessing task is running.  I did add a call to SignInToPortal call but that did not fix the problem.

 

DonMorrison1_0-1727669788289.png

 

0 Kudos
DonMorrison1
Frequent Contributor

According to ESRI support:  

Unfortunately, it does seem that accessing protected URLs directly via arcpy within a geoprocessing task is not feasible due to how the arcpy library handles security for such resources. Using REST APIs with a token-based authentication is a reliable alternative.

0 Kudos