Select to view content in your preferred language

Using the POST Method for Batch Geocoding with ArcGIS Server?

06-11-2019 12:41 PM
Occasional Contributor III

I'm trying to hit my geocoding servers REST API:[] (ArcGIS Server 10.6.1)

using the POST method (which, BTW, could use an example or two, there only seems to be this VERY brief "note" on WHEN to use POST, not HOW:

I'm trying to use the, and I think I've managed to get the token accepted, etc..., but I keep getting:

{'error': {'code': 400, 'message': 'Unable to complete operation.', 'details': []}}

Which, based on my experience with using the GET method, means something is wrong with the way I am formatting the submitted data? Though, I've been cutting and pasting directly from the Esri Help file examples for GET, but I'm not sure that's what is needed for POST. Any thoughts on how to proceed are welcome. I'm about to see what adding headers might do?

Here's my code:

# import the requests library
import requests

# Multiple address records
 "records": [
 "attributes": {
 "Street": "380 New York St.",
 "City": "Redlands",
 "Region": "CA",
 "ZIP": "92373"
 "attributes": {
 "Street": "1 World Way",
 "City": "Los Angeles",
 "Region": "CA",
 "ZIP": "90045"

# Parameters
# Geocoder endpoint
URL = ''
# token from
mytoken = <GeneratedToken>
# output spatial reference id 
outsrid = 4326
# output format
format = 'pjson'
# params data to be sent to api 
params ={'outSR':outsrid,'f':format,'token':mytoken}

# Use POST to batch geocode
r =, data=addresses, params=params)


I've altered the attribute names for my service, as seen here:

Address Fields:
  • Street ( type: esriFieldTypeString , alias: Street or Intersection , required: false , length: 100 )
  • City ( type: esriFieldTypeString , alias: City or Placename , required: false , length: 40 )
  • State ( type: esriFieldTypeString , alias: State , required: false , length: 100 )
  • ZIP ( type: esriFieldTypeString , alias: ZIP Code , required: false , length: 10 )
0 Kudos
1 Reply
New Contributor III

I was having the same issue and this post on GIS Stack Exchange led me to the solution. The post data needs to be passed as a dictionary with an 'addresses' key and the records converted to a JSON string as its value. Using your example:

import json
r =, params=params, data={'addresses': json.dumps(addresses)})
0 Kudos