How to attach token to addFeatures post?

1259
2
Jump to solution
09-29-2016 06:34 PM
GregStevenson
New Contributor III

Hi all,

Im trying to 'addFeatures' to a server feature service but keep getting the error:

"error": {
"code": 499,
"message": "Token Required",
"details": []

My token is legit but I don't think i'm attaching it to my request properly. I've put the relevant part of my script below. Where does my error lie? Its my first time trying to add features to a service.

 

request = urllib2.Request(endPoint, {'Content-Type': 'application/json'})

request.add_header ('Authorization', 'token %s' % Token )


response = urllib2.urlopen(request, data).read()

Thanks,

Greg

0 Kudos
1 Solution

Accepted Solutions
JonathanQuinn
Esri Notable Contributor

The token isn't a header, it should be included in the body of the request.  Include it within the data variable you're sending along with the request, (along with the add features JSON).

View solution in original post

2 Replies
JonathanQuinn
Esri Notable Contributor

The token isn't a header, it should be included in the body of the request.  Include it within the data variable you're sending along with the request, (along with the add features JSON).

GregStevenson
New Contributor III

Nailed it. Thanks Jonathan

0 Kudos