HTTP 200 OK vs 201 Created
Both HTTP 200 (OK) and 201 (Created) belong to the 2xx Success category. 200 indicates that the request succeeded. The meaning depends on the HTTP method: GET returns the resource, POST reports the action result, HEAD returns headers only. Meanwhile, 201 means that the request succeeded and a new resource was created. Typically returned after POST or PUT requests that create a new entity.
คำอธิบาย
The request succeeded. The meaning depends on the HTTP method: GET returns the resource, POST reports the action result, HEAD returns headers only.
เมื่อคุณพบเห็น
The most common HTTP response — indicates the request was processed successfully.
วิธีแก้ไข
No fix needed. The request succeeded as expected.
คำอธิบาย
The request succeeded and a new resource was created. Typically returned after POST or PUT requests that create a new entity.
เมื่อคุณพบเห็น
After successfully creating a new user, post, order, or other resource via a REST API.
วิธีแก้ไข
No fix needed. Check the Location header for the URL of the new resource.
ความแตกต่างหลัก
HTTP 200: The request succeeded. The meaning depends on the HTTP method: GET returns the resource, POST reports the action result, HEAD returns headers only.
HTTP 201: The request succeeded and a new resource was created. Typically returned after POST or PUT requests that create a new entity.
You encounter 200 when the most common HTTP response — indicates the request was processed successfully.
You encounter 201 when after successfully creating a new user, post, order, or other resource via a REST API.
ควรใช้อันไหนเมื่อไร
For 200 (OK): No fix needed. The request succeeded as expected. For 201 (Created): No fix needed. Check the Location header for the URL of the new resource.