Hacker News new | ask | show | jobs
by oxtopus 4769 days ago
Something to consider, the author advocates json responses across the board, which is pretty good advice, however, it's incompatible with `204 No Content` responses (also recommended). If you're building a client that connects to an API that could potentially return a `204 No Content` response, you can't assume that there will be json in the body and automatically parse the response.
1 comments

I don't see the problem here. You get a 204, you don't expect content. If your consumer hits a URL, ignores status codes, and expects content, You're Doing It Wrong.

To me, it looks like the HTTP equivalent of a C function that returns NULL.

Agreed. Just throwing it out there since I've encountered it before, more than once, where others assume there will always be a response, regardless of status code.