AnsweredAssumed Answered

A Python Web Tool is unable to access a hosted feature service

Question asked by akocjan on Mar 13, 2020
Latest reply on Mar 17, 2020 by akocjan

I have created a simple script tool that should get one parameter (a feature class) and print some unique values from a single field. The Python code looks like this:

 

import arcpy

def get_species(observationFeatureClass, field, query):
    with arcpy.da.SearchCursor(observationFeatureClass, [field], query) as species:
        return sorted({s[0] for s in species})

ofc = arcpy.GetParameterAsText(0)
fld = "gatunek"
qry = "kategoria = 'inwazyjna'"

for i, s in enumerate(get_species(ofc, fld, qry), start=1):
    arcpy.AddMessage(f"Gatunek nr {i}: {s}")

If I run this tool straight from the ArcGIS Pro, providing a hosted feature service as a parameter, everything works well. But, when I publish the result as a Web Tool on our portal, it is unable to access the service and it returns: "RuntimeError: cannot open <Hosted Feature Service URL here>".

Previously, we had a problem with accessing protected resources from a custom print service and it was resolved by applying a patch, but this tool fails regardless of the service permissions.

We work with ArcGIS Pro 2.5 and ArcGIS Enterprise 10.7.

Outcomes