Which HTTP status code is commonly used to indicate that a resource has been created as a result of a POST request?

Prepare for the CDX 182A Exam with comprehensive flashcards and multiple choice questions, each complete with hints and thorough explanations. Ace your test with our well-structured study materials!

Multiple Choice

Which HTTP status code is commonly used to indicate that a resource has been created as a result of a POST request?

Explanation:
When a POST creates a new resource, the standard response is to indicate that something was created as a result of the request. 201 Created communicates both success and that a new resource now exists. It’s common for the response to include a Location header with the URL of the newly created item and, often, a representation of the resource in the response body so the client can immediately work with it. Other options don’t fit this exact pattern. A generic 200 OK means the request succeeded but doesn’t explicitly signal that a new resource was created, making the result ambiguous. A 204 No Content indicates success with no body, which isn’t suitable when the client needs access to the new resource’s details or its URL. A 202 Accepted means the request has been accepted for processing, but the creation may not be complete yet, so it doesn’t guarantee that a resource exists immediately. So, 201 Created is the best answer when a POST results in the creation of a new resource.

When a POST creates a new resource, the standard response is to indicate that something was created as a result of the request. 201 Created communicates both success and that a new resource now exists. It’s common for the response to include a Location header with the URL of the newly created item and, often, a representation of the resource in the response body so the client can immediately work with it.

Other options don’t fit this exact pattern. A generic 200 OK means the request succeeded but doesn’t explicitly signal that a new resource was created, making the result ambiguous. A 204 No Content indicates success with no body, which isn’t suitable when the client needs access to the new resource’s details or its URL. A 202 Accepted means the request has been accepted for processing, but the creation may not be complete yet, so it doesn’t guarantee that a resource exists immediately.

So, 201 Created is the best answer when a POST results in the creation of a new resource.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy