Apparently, POST /api/things returns HTTP 200 - however, 201 is the right code.
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.
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.
up!
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
+1
Any update on this issue? Almost a year now for something I would deem critical to REST patterns and service integrators.
:+1:
Having switched to loopback for my webservice layer I'm having to change all my tests and checks because of this inconsistency.
@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.
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: https://github.com/strongloop/loopback-next/issues/788
Most helpful comment
Having switched to loopback for my webservice layer I'm having to change all my tests and checks because of this inconsistency.