I'm inserting new points using the ArcGIS Server REST API addFeatures method - this is working correctly.

However, I'm finding that when the JSON reaches a certain (undefined) threshold the POST fails with a 404. If the JSON is reduced in size the (otherwise identical) POST succeeds.

I can't see any inherent limits in Python's request functionality. Is this a known limitation with the ArcGIS Server REST API, or are there any workarounds?

Below is some code to reproduce the problem, using a sample Esri server so you can test it.

The target field has a width of 60 so it's expected that the insertion will return an error message with a string 1000 characters long. But note that it errors with a 404 when the string is 3000 characters long.

import json, requests

for num in [10, 1000, 3000]:

    # The following works with 10, gives a legitimate error with 1000, and gives a 404 with 3000
    value = "a" * num

    data = [{"attributes": {'address': value}, "geometry": {"x": 0,"y": 0 }}]
    params = {"f": "json","features": json.dumps(data)}
    headers = {'content-type':'application/json','Accept':'application/json'}
    response = requests.post("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0/addFeatures", headers=headers, params=params)
    print("With number = " + str(num) + " the response is " + response.text)


With number = 10 the response is {"addResults":[{"objectId":18209901,"globalId" : null,"success":true}]}

With number = 1000 the response is {"error":{"code":400,"message":"Unable to complete operation.","details":["Unable to add features"]}}

With number = 3000 the response is 404 - File or directory not found.

Why does posting the long JSON string return a 404, and how can this be resolved?

  • It's too long ago for me to remember the details but I have a suspicion that you may be striking a limit of 1024 on a URL. I got past it here with help from Jason Scheirer and Paul Cavallaro: gis.stackexchange.com/questions/19721/…
    – PolyGeo
    Feb 3, 2016 at 5:59
  • @polygeo thanks for the tip - but I think take the query (everything after the ?) and jam it in the data argument is basically what I've done by sending the object as params=params, which contains json.dumps(data)? PS I've updated the code so you can verify this Feb 3, 2016 at 9:39
  • 1
    When I POST in JavaScript, the data goes as data, not parameters (POST can have both). Use your browser diagnostic to see what is actually being sent.
    – Vince
    Feb 3, 2016 at 12:39

2 Answers 2


SampleServer3 = ArcGIS 10.0.

SampleServer6 = 10.3.

As suggested, its the server which is having problems, not your code. The following works against 10.3 - note I modified your code to use built-ins instead of Requests. (Remember, Server underwent massive changes between 10.0 and 10.1. If you're stuck at 10.0 I'd suggest looking to upgrade as soon as possible. You can see here that 10.0 has been retired)

import json
import urllib
import urllib2

#url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0/addFeatures"
url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/1/addFeatures"
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}

for num in [10, 1000, 3000]:

    value = "a" * num
    data = [{"attributes": {'address': value}, "geometry": {"x": 0,"y": 0 }}]
    params = {"f": "json","features": data}

    req = urllib2.Request(url, urllib.urlencode(params).encode('UTF-8'), headers)
    response = urllib2.urlopen(req).read()
    response_text = response.decode('UTF-8')
    response_json = json.loads(response_text)
    print response_json

{u'addResults': [{u'success': True, u'objectId': 29413}]}

{u'addResults': [{u'success': True, u'objectId': 29414}]}

{u'addResults': [{u'success': True, u'objectId': 29415}]}

  • Many thanks for this, it's exactly the sort of tweak I was hoping existed. (I'm actually using ArcGIS Online for this, so it's Server 10.3, but my original code sample failed there too) Feb 3, 2016 at 19:25

As @polygeo suggests, POST requests do have a size limit, but it depends on server and browser. https://stackoverflow.com/a/2880777/3182496

  • Thanks for the tip, but are you positive that's what's happening here? It doesn't seem like that string would be anywhere near 2Gb. I've updated the question with a simpler sample to demonstrate the problem Feb 3, 2016 at 9:40
  • I don't know, but POST does have some odd behaviour. I've had string parameters like "2.00" rounded and returned to me as a string of "2". There must be all kinds of "helpful" optimisations going on under the hood.
    – jon_two
    Feb 3, 2016 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.