• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

REST API Tutorial

  • REST
  • JSON
  • Dark Mode
Home / HTTP Status / HTTP Status 201 (Created)

HTTP Status 201 (Created)

HTTP Status 201 indicates that as a result of HTTP POST request, one or more new resources have been successfully created on server.

HTTP Headers

The response may contain URI in Location header field in HTTP headers list, which can have reference to the newly created resource. Also, response payload also may include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field.

The origin server MUST create the resource before returning the 201 status code. If the action cannot be carried out immediately, the server SHOULD respond with 202 (Accepted) response instead.

Lost update problem

HTTP 201 response MAY contain an ETag response header field indicating the current value of the entity tag for the requested variant just created. ETag header field can be used in later conditional requests to prevent the “lost update” problem.

Lost update problem happens when multiple people edit a resource without knowledge of each others’ changes. In this scenario, the last person to update a resource “wins”, and previous updates are lost. ETags can be used in combination with the If-Match header to let the server decide if a resource should be updated. If ETag does not match then server informs the client via a 412 (Precondition Failed) response.

Reference: 201 (Created)

Was this article helpful?

Share this:

  • Twitter
  • Facebook
Previous Tutorial:
HTTP Status 200 (OK)
Next Tutorial:
HTTP Status 202 (Accepted)

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Search Tutorials

Learn REST

  • What is REST?
  • REST Constraints
  • REST Resource Naming Guide

Guides

  • Caching
  • Compression
  • Content Negotiation
  • HATEOAS
  • Idempotence
  • Security Essentials
  • Versioning
  • Statelessness in REST APIs

Tech – How To

  • REST API Design Tutorial
  • Create REST APIs with JAX-RS

FAQs

  • PUT vs POST
  • N+1 Problem
  • ‘q’ Parameter

Resources

  • What is an API?
  • Comparing SOAP vs REST APIs
  • HTTP Methods
  • Richardson Maturity Model
  • HTTP Response Codes
    • 200 (OK)
    • 201 (Created)
    • 202 (Accepted)
    • 204 (No Content)
    • 301 (Moved Permanently)

Footer

References

  • The dissertation by Roy Thomas Fielding
  • Uniform Resource Identifier (URI, URL, URN) [RFC 3986]
  • Internet MediaTypes
  • Web Application Description Language (WADL)

Meta Links

  • About
  • Contact Us
  • Privacy Policy

Blogs

  • How To Do In Java

Copyright © 2020 · restfulapi.net · All Rights Reserved. | Sitemap