Skip to content

HTTP REST inconsistency: create should return HTTP 201 #360

Closed

Description

@fabien

Apparently, POST /api/things returns HTTP 200 - however, 201 is the right code.

Activity

  1. added this to the milestone on Jul 7, 2014
  2. raymondfeng commented on Jul 7, 2014

    @raymondfeng
    Member

    I agree that POST for creation should return HTTP 201. In addition, there should be a 'Location' header with a URL points to the instance being created, for example:

    Location: http://localhost:3000/api/things/1

    Since it will be a breaking change, we'll probably have to fix it in 2.x stream.

  3. gcirne commented on Aug 4, 2014

    @gcirne
    Contributor

    Hey guys,

    Any news on this issue?

    I could probably provide a PR for it but I would need some pointers on where the changes should be made.

  4. albertoleal commented on Aug 14, 2014

    @albertoleal
    Contributor

    up!

  5. zbitname commented on Aug 14, 2014

    @zbitname

    Should be so:
    POST /api/things returns HTTP 201
    PUT /api/things/:id returns HTTP 200
    GET /api/things/:id returns HTTP 200
    GET /api/things returns HTTP 200 or 206 if need "Range"
    DELETE /api/things/:id returns HTTP 204

  6. wpjunior commented on Aug 14, 2014

    @wpjunior

    +1

  7. modified the milestone: #Rel lb 2.0.0 on Sep 30, 2014
  8. added this to the LoopBack 3.0 milestone on Nov 26, 2014
  9. wrensburg commented on May 7, 2015

    @wrensburg

    Any update on this issue? Almost a year now for something I would deem critical to REST patterns and service integrators.

  10. seriousben commented on May 7, 2015

    @seriousben
    Contributor

    👍

  11. slyadams commented on Feb 24, 2016

    @slyadams

    Having switched to loopback for my webservice layer I'm having to change all my tests and checks because of this inconsistency.

  12. removed this from the #Epic: LoopBack 3.0 milestone on May 24, 2016
  13. brawaga commented on May 15, 2017

    @brawaga

    @zbitname, PUT also might and should return 201 if the request led to instance creation. 200 for rewriting existing one only. DELETE may return 200 in case you decide to design your API in way DELETE to return deleted item in response.

  14. bajtos commented on Mar 10, 2020

    @bajtos
    Member

    LoopBack 3 is in Maintenance LTS mode, only critical bugs and critical security fixes will be provided. We are tracking this request for LoopBack 4 here: loopbackio/loopback-next#788

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions