I'm trying to insert an item to a list and I keep getting bad request so it's probably because my json is wrong?

Here's what my json looks like:


securit_x00e9_ it's because I used this letter: é and apparently when I checked the xml it's translated to _x00e9_.

So is this json wrong?

The header and content type is set to application/json; odata: verbose. And I require form digest

MERGE https://mysite/_api/Web/Lists/GetByTitle('myDelphiTestList') HTTP/1.1
Connection: Keep-Alive
Accept: application/json; odata=verbose
If-Match: "5"
User-Agent: Mozarella/1.0 (compatible; Indy Library)
X-RequestDigest: 0x7E78B662646D13B263E3B9964C4D5554F0795C67CB99EFB37D7BA8FB2997DB1D748634497241F0F0BDA1AFF887971D1D2CF98E0739AF5E0969D201AEA834BBE2,28 Jul 2016 09:12:52 -0000
Content-Length: 79
Host: mysite
Authorization: Basic eW91cmljdFw2MDEyNzA4NjY6RGV0cm9pdCUxNTM0Mg==


Your JSON for updating list item should be like this.

"__metadata":{ "type":"SP.Data.YourListNameListItem"},

In type you must write "SP.YourListNameListItem"


Try removing securit_x00e9_":"test" line from your JSON, if its update then you have to try the JSON as

    "__metadata":{ "type":"SP.Data.YourListNameListItem"},

Update-2 :

Based on your commented error message

"The given key was not present in the dictionary"

Your headers should look like this

headers = {'X-RequestDigest': token,
           'Accept': 'application/json; odata=verbose',
           'Content-Type': 'application/json; odata=verbose',
           'Content-Length': lengthofbody}

We can avoid 'Content-Length' header. I tried without this header, It worked.



Please ensure that your url should be like


Also your HTTP Methods should be POST

| improve this answer | |
  • My list is called "myDelphiTestList" So i tried SP.myDelphiTestListListItem. It still gives a bad request error. – Tanaka J. Jul 28 '16 at 8:33
  • updated answer. Try with SP.Data.ListnameListItem. – Aakash Maurya Jul 28 '16 at 8:34
  • Same error. Bad request – Tanaka J. Jul 28 '16 at 8:36
  • Lastly try once with removing your 'security_x00ep_' field from json. If it updates then there might be issue in this field – Aakash Maurya Jul 28 '16 at 8:36
  • 1
    YES! That was close, just didn't need the '(5)' and also use http method of POST and not MERGE. And it works now. Thank you for the time taken :) Adapt your answer to these things and i will accept it as an answer cause you partially helped me :) – Tanaka J. Jul 28 '16 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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