MDN Web Docs

Status

http

200 OK

Examples

Receiving a 200 OK for a GET request

In this example, a successful GET request to https://example.com returns a 200 OK response. The response includes representation headers and a message body with the HTML content:

http

HTTP/1.1 200 OK
Accept-Ranges: bytes
Age: 294510
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Fri, 21 Jun 2024 14:18:33 GMT
Etag: "3147526947"
Expires: Fri, 28 Jun 2024 14:18:33 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Server: ECAcc (nyd/D10E)
X-Cache: HIT
Content-Length: 1256
<!doctype html>
<!-- HTML content follows here -->

Receiving a 200 OK for a POST request in form submission

Assuming a form exists to send data to an endpoint for managing subscriptions at http://example.com/subscribe. A POST request to subscribe a user may look like the following:

http

POST /subscribe HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 50
name=Brian%20Smith&email=brian.smith%40example.com

In this example, a response with a 200 OK status could look like this:

http

HTTP/1.1 200 OK
Content-Type: application/json
{
  "message": "User subscription pending. A confirmation email has been sent.",
  "subscription": {
    "name": "Brian Smith",
    "email": "brian.smith@example.com",
    "id": 123,
    "feed": "default"
  }
}

Specifications

Specification
HTTP Semantics
# status.200

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗