I have an API that I'm testing with and if I submit my data through "form-data" with the following values it works:
key: response[comment]
value: This is a test
But if I do some custom JSON in the "raw" tab with the following structure, it doesn't work:
{ "response[comment]": "This is a test" }
It's driving me nuts to be honest as the server doesn't give me any details on what's wrong. I have the feeling it's the encoding of the object that goes wrong, but I'm using Angular and I get the same 400 error, while I'm fairly sure it should just work with a JS object as the data on a .post.
Any help would be appreciated!
Ensure your Content-Type
header!
If your raw data is JSON: Content-Type: application/json
I experienced a similar issue to yours: my request was working using the form-data, but not as raw... and after debugging the request server side, I realised my request Content-Type was "text/plain;charset=UTF-8"
.. even if JSON was selected in the side dropdown...
Hope it saves time to the next one ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With