HTTP Status Code 200 (OK)

The HTTP Status 200 (OK) status code indicates that the request has been processed successfully on the server. The response payload depends on the HTTP method that was selected for the request.

The HTTP Status 200 (OK) status code indicates that the request has been processed successfully on the server. The response payload depends on the HTTP method that was selected for the request.

The HTTP 200 status code is defined in RFC-7231, which is part of the broader RFC 7230-7235 series that describes the HTTP/1.1 protocol. The document provides comprehensive information about its usage and semantics. It’s the go-to resource to understand the intricacies of HTTP 200.

1. Response Entity

HTTP status code 200 is used in a variety of scenarios, all of which share the common theme of successful client requests. The response body depends on the HHTP method used and can be interpreted as follows:

HTTP Method
Response Payload
GET
An entity corresponding to the requested resource is sent in the response.
HEAD
The response has only HTTP header fields and no payload is sent in response.
POST
The response generally contains information about progress status representation or the result of an action that was performed in request.
PUT
Progress status representation of request is sent in response.
DELETE
Progress status representation of request is sent in response.
OPTIONS
A list of valid request methods associated with the resource using Allow header. e.g.

Allow: HEAD, GET, OPTIONS
Content-Length: 18
Content-Type: text/plain;charset=UTF-8
Date: Thu, 06 Apr 2017 06:43:59 GMT
Server: Apache-Coyote/1.1
TRACE
A representation of the request message as received by the end server.

3. HTTP Headers

While an HTTP 200 response generally indicates success, the accompanying headers can convey details about the requested resource, caching, and content types.

  • Content-Type: Specifies the media type (e.g., JSON, HTML) of the response body.
  • Content-Length: Indicates the size of the response content in bytes.
  • Cache-Control: Defines caching directives for the client or intermediary caches.
  • Last-Modified: Informs the client about the resource’s last modification date.

These headers are crucial for understanding the nature of the response and how the client should handle it.

3. Important Facts

  • A 200 response always has a payload, though an origin server MAY generate a payload body of zero length or empty payload.
  • If the server does not want to send any payload in response, then it should send HTTP status 204 (No Content) instead.
  • By default, 200 (OK) responses (header and payload) are cacheable. If caching needs to be overridden then the response must include cache respective cache headers.
  • Never return HTTP 200 for failed requests.

Happy Learning !!

Comments

Subscribe
Notify of
guest
6 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Sap M

Hi , Am trying to create a new account and am getting JSON response as ”

” in Rest service.
RAW tab has the following information” HTTP/1.1 200 OK
Date: Thu, 19 Sep 2019 20:02:31 EST
Content-Length: 14
Content-Type: application/json
X-UA-Compatible: IE=edge,chrome=1

How can I see my requested account number in the response field.

Jim

Do you have to manually return a 200 response code or is this handled by the server?
If manual, how do you return the code?

Kuldip Shah

Hi, For response code 200, Can the body use “one of” entity? i.e. in some condition, 200 will receive Entity1 and other condition, 200 will receive Entity2?