Select to view content in your preferred language

Using ArcGIS API for Python with no auth against a self-hosted geocoding service

102
1
a week ago
Labels (1)
StaceMaples
Frequent Contributor

I'm running a geocoding service on ArcGIS Server, using a Web Adapter, and no Portal.

The service has no authentication on it, as the server is scoped to our internal IP range. 

I'm trying to figure out how to batch geocode against my service using the ArcGIS API for Python, which seems pretty straightforward, except that I can't figure out how to authenticate as an anon user. The examples in the Authentication guidance are for a portal instance, which I don't have.

gis = GIS()

Doesn't seem to work. I keep getting the  error:

Exception: Token required but not passed in the request. Token required. (Error Code: 499)

 Again, there is no auth on the server, at all. I can submit simple GET requests all day long, successfully, but would like to use the Python API for what I am trying to do, right now. 

The service endpoint is similar to the following, if it's informative:

https://service.server.com/arcgis/rest/services/geocode/USA/GeocodeServer

 

Any thoughts or guidance is appreciated. 

 

Stace

 

0 Kudos
1 Reply
Clubdebambos
MVP Regular Contributor

Hi @StaceMaples,

While I have no direct experience with this I hopefully get you going in the right direction.

As you are not accessing a Portal (or AGOL) you may not need the GIS() call at all. 

I would try this based on the Geocoder documentation.

## import Geocoder class
from arcgis.geocoding import Geocoder

## the URL to you Geocoder service
geocoder_url = "https://service.server.com/arcgis/rest/services/geocode/USA/GeocodeServer" 

## create a Geocoder object
geocoder = Geocoder(location = geocoder_url)

## batch geocode
## see https://developers.arcgis.com/python/latest/api-reference/arcgis.geocoding.html#geocoder
## for properties and mehods available for the Geocoder class.
geocoder.batch_geocode(
    addresses = [],
    ...
)

 

Please let us know if this is of any help or solves your problem.

All the best,

Glen

 

~ learn.finaldraftmapping.com
0 Kudos