matthew-andrews / isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify
MIT License
6.95k stars 289 forks source link

REST service POST call gives 400 bad request #118

Closed sikhsra closed 7 years ago

sikhsra commented 7 years ago

When hitting POST method without body(as per requirements) it gives 400 bad request with contentType as application/json. Is there a way to call empty POST with contentType as application/json?

{ method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }

matthew-andrews commented 7 years ago

I think it depends on the server you are sending the request too.

It's of course possible to send an empty POST request with the header Content-Type: application/json but it would not be unreasonable for a server respond with 400 bad request.