Home2xx – HTTP Status CodesUncategorized2xx – HTTP Status Codes

2xx – HTTP Status Codes

2xx – Accepted

These HTTP status codes indicate that the server successfully received, comprehended, and processed the client’s request. They reflect successful interactions in which the server performed the requested action.

200 – OK

This status code indicates that the client’s request was processed successfully. The server’s response shows that the requested action was completed and that the client has received the intended information or results. It is the most common status code, and it is commonly observed in successful webpage requests, file downloads, and data submissions.

Example of a 200: OK

A user updates their profile information by filling out a form on a website. The request is processed by the server, and the profile is updated. It then returns a response with the status code 200 OK, indicating that the activity was successful. Following that, the user’s web browser may display a confirmation message or redirect to an updated profile page.

201 – Created

When a client’s request results in the creation of a new resource on the server, this response code is used. It confirms that the request was not only successful, but also resulted in the creation of a new resource, which is frequently the outcome of POST or PUT operations. The answer often contains information about the newly created resource, such as characteristics and a URI (Uniform Resource Identifier) specifying its location. This enables the client or user agent to immediately access or refer to the new resource.

Example of a 201: Created

A developer uses a REST API to add a new item to a database, sending a POST request with the item’s data. The server successfully creates the item in the database and returns a 201 Created status code. Along with this code, the server includes in the response the URI of the newly created item, allowing the developer to directly access or reference this new resource.

Leave a Reply

Your email address will not be published. Required fields are marked *