HTTP

HTTP 201 Created vs 202 Accepted

Both HTTP 201 (Created) and 202 (Accepted) belong to the 2xx Success category. 201 indicates that the request succeeded and a new resource was created. Typically returned after POST or PUT requests that create a new entity. Meanwhile, 202 means that the request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon.

Açıklama

The request succeeded and a new resource was created. Typically returned after POST or PUT requests that create a new entity.

Gördüğünüzde

After successfully creating a new user, post, order, or other resource via a REST API.

Nasıl Düzeltilir

No fix needed. Check the Location header for the URL of the new resource.

Açıklama

The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon.

Gördüğünüzde

For async operations like batch jobs, email sending, or background tasks that take time to complete.

Nasıl Düzeltilir

Poll the provided status URL or wait for a callback/webhook.

Temel Farklar

1.

HTTP 201: The request succeeded and a new resource was created. Typically returned after POST or PUT requests that create a new entity.

2.

HTTP 202: The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon.

3.

You encounter 201 when after successfully creating a new user, post, order, or other resource via a REST API.

4.

You encounter 202 when for async operations like batch jobs, email sending, or background tasks that take time to complete.

Hangisini Ne Zaman Kullanmalı

For 201 (Created): No fix needed. Check the Location header for the URL of the new resource. For 202 (Accepted): Poll the provided status URL or wait for a callback/webhook.

Daha Fazla Öğren