Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is 200 OK required to have response body?

Tags:

rest

jax-rs

Does a 200 OK response mandate a response body?

I know that 204 code is for a response for which there is no response body. But what semantics for 200?

like image 623
Trying Avatar asked May 21 '15 20:05

Trying


People also ask

What does a 200 response mean?

The HTTP 200 OK success status response code indicates that the request has succeeded. A 200 response is cacheable by default. The meaning of a success depends on the HTTP request method: GET : The resource has been fetched and is transmitted in the message body.

Should REST API always return 200?

However, they told me specifiying status code like 400, 404, 300, is part of RESTful API, and returning always 200 is the right status code because the server responded and it is alive. APIs, always have to return 200 except 500. Because when the server dies, it can't return anything.

What is the difference between 200 and 200 OK?

So the answer is: There are no differences is if the response shows with OK or something other, or nothing. 200 means OK and this the most important information. Status message is only human readable transcription of 200 and it is not important for browser.

Can HTTP POST 200 return?

HTTP Status Code 200: The "OK" ResponseAn HTTP status code 200 means success. The client has requested documents from the server. The server has replied to the client and given the client the documents.


1 Answers

From RFC 7231 6.3.1. 200 OK

Aside from responses to CONNECT, a 200 response always has a payload, though an origin server MAY generate a payload body of zero length. If no payload is desired, an origin server ought to send 204 (No Content) instead.

like image 150
Paul Samsotha Avatar answered Oct 05 '22 06:10

Paul Samsotha