Using Python API to create and query a restricted and unfederated feature service

06-18-2020 10:39 AM
Occasional Contributor III

I'm aware of how to use the Python API to authenticate to a GIS and then create a FeatureLayer from a feature service to query or extract data from.  

However, I can't seem to figure out how to do the same when there is no underlying Portal.  

The feature service in question is restricted, but I am able to login and traverse the REST endpoints from my browser.  Similarly, I can (using Python) generate a token from the Server's generateToken endpoint.  However, since the server is not federated, I am not able to use the Python API to get access to the underlying feature services:

For my example: say my REST endpoints are at:

Example code:

gis = GIS("", username=username, password=password) - generates an error

fl = arcgis.features.FeatureLayer("").query() - also generates an error.  

I have tried generating a token and then passing it in to both the Feature layer or the GIS and nothing seems to work.  Is there any workaround here I'm missing?


0 Kudos
1 Reply
Occasional Contributor III

Nevermind - just realized there is a arcgis.gis.server module that solves my issue.  Figured it out.  

gis = arcgis.gis.server.Server("", username=username, password=password)

fl = arcgis.features.FeatureLayer(featurelayerurl, gis=gis).query()

0 Kudos