request / request-promise

The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.
ISC License
4.77k stars 297 forks source link

'{}' is invalid JSON #338

Open lolpez opened 4 years ago

lolpez commented 4 years ago

I have an API which returns as response '{}' when a method DELETE worked. image

However when using the option json: true, I get the following error: '400 - {"err":"Invalid json","ECODE":"JSON_001"}' image

The option is supposed to parse the response body as JSON so I should get an empty object as response {}.

I believe when JSON parsing '{}' returns {} which is valid. image

Why is this happening?

analog-nico commented 4 years ago

What you have here is actually not related to the response but instead you get a 400 status code from your API. That means that the JSON in your request is wrong. Please double check your data variable.