I'm attempting to addFeatures in a .py script to an ArcGIS Server feature service. Can anyone spot an issue with the payload?
My source code:
queryURL_dalId = DALfs + "/addFeatures"
params = urllib.urlencode({'f': 'json',
'features': json.dumps(feat),
'token': genTokenAGS()})
req = urllib2.Request(queryURL_dalId, params)
response = urllib2.urlopen(req)
jsonResultApp = json.load(response)
print jsonResultApp
#the result print is:
#{u'error': {u'message': u'Unable to complete operation.', u'code': 500, u'details': [u'Parser error: Some parameters could not be recognized.']}}
The params "feature" attribute looks like this:
{
"geometry": {
"rings": [
[
[
-8916035.78019179,
3084661.19599559
],
[
-8915988.0070495,
3085052.93576556
],
[
-8915529.38488079,
3085148.48205013
],
[
-8915424.28396684,
3084804.51542474
],
[
-8914889.22476772,
3084833.17930828
],
[
-8914593.03128233,
3084336.33862437
],
[
-8913924.20728573,
3084365.0025102
],
[
-8913859.51668594,
3083941.53976998
],
[
-8914444.27714894,
3083843.30241113
],
[
-8915008.00023389,
3083843.30241113
],
[
-8916035.78019179,
3084661.19599559
]
]
]
},
"attributes": {
"activityLogId": "DAL-999",
"scheduleId": "SCH-9",
"agency": "blah"
}
}
Thanks for looking!
Solved! Go to Solution.
It looks like the payload didn't contain "[" "]" brackets around the features parameter. I made that into a variable instead of setting directly from json.dumps(feat) and it seemed to work.
paramFeatures = json.dumps(feat)
params = urllib.urlencode({'f': 'json',
'features': paramFeatures,
'token': genTokenAGS()})
It looks like the payload didn't contain "[" "]" brackets around the features parameter. I made that into a variable instead of setting directly from json.dumps(feat) and it seemed to work.
paramFeatures = json.dumps(feat)
params = urllib.urlencode({'f': 'json',
'features': paramFeatures,
'token': genTokenAGS()})