HTTP 201 Created — What It Means & How to Fix It
About HTTP 201 Created
The HTTP 201 Created status code indicates the request has been fulfilled and a new resource has been created on the server. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: This status code is returned when a POST or PUT request successfully creates a new resource.. The response should include a Location header pointing to the new resource URL.. The response body typically contains the representation of the newly created resource.. It is the preferred response code for successful resource creation in RESTful APIs.. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: A POST request successfully created a new resource on the server.. A PUT request created a resource at the specified URI.. A user registration, form submission, or data insertion completed successfully.. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Check the Location header in the response for the URL of the new resource.. Verify the response body contains the created resource with its assigned ID.. If you expected 201 but got 200, review the server endpoint implementation.. Use the returned resource data to update your client-side state.. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our HTTP Status Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
What is the difference between 200 and 201?
200 OK means a general success, while 201 Created specifically indicates a new resource was created. Use 201 for POST endpoints that create new records.
Overview
The HTTP 201 Created status code indicates the request has been fulfilled and a new resource has been created on the server.
Key Details
- This status code is returned when a POST or PUT request successfully creates a new resource.
- The response should include a Location header pointing to the new resource URL.
- The response body typically contains the representation of the newly created resource.
- It is the preferred response code for successful resource creation in RESTful APIs.
Common Causes
- A POST request successfully created a new resource on the server.
- A PUT request created a resource at the specified URI.
- A user registration, form submission, or data insertion completed successfully.
Steps
- 1Check the Location header in the response for the URL of the new resource.
- 2Verify the response body contains the created resource with its assigned ID.
- 3If you expected 201 but got 200, review the server endpoint implementation.
- 4Use the returned resource data to update your client-side state.