Photo by Joanna Kosinska on Unsplash
For more than 10 years we've been working with HTTP and APIs following the ReST architecture. Most people thi...
For further actions, you may consider blocking this person and/or reporting abuse
Thanks for the great post Lucas.
I have A REST API with several POST endpoints that take in data, but return no data. Currently I’m returning status code 204 no content. Is that correct or should I just return 200 OK?
It depends on what your POST requests do. For example, if your POST request is creating or updating something, then you should return 201 AND the created or updated resource, otherwise, if this is only something that will be processed later, you should return 202.
But, in the last case, if you're just doing an atomic transaction like "follow a user" or so, then 204 is just fine.
Hey Lucas, thanks for the reply. Most of the POSTS are for controlling a service (Start/Stop) kind of commands.
Oh! In this case, my personal opinion is that you can use either 200 OR 204, I'd use 204 since it has no content to be returned, but if you do return something go for 200
Great write up Lucas, I was chatting about this just last night and thought to myself I wonder if I'm returning the write code. Now I know, so thankyou :-)
401/403 are ones that always catch me out
Awesome! Thanks a lot for commenting! This is being a very fun article to write about :D
It may be good to also write about status 204, as it is also used quite often.
I wrote about it in the second part :D those we do not see too much but we should
Very good series about HTTP Status Codes. Congratulations !
The cats were very helpful with this lesson, thank you!
After discover "http status dogs" i became the inspector of status codes.
Status dogs have explanation. Status cats don't.
Que artigo perfeito!
Loved this article, it helped me understand minor differences between status codes and when to use what