Inconsistent response codes for "resource created" responses
See original GitHub issueWe have some inconsistency with the response codes returned for “resource created” responses. Some are returning 201 Created
whereas others are returning 200 OK
.
From my recent experience:
POST /posts/
returns201
POST /webhooks/
returns201
POST /subscribers/
returns200
POST /invites/
returns200
The response code is determined by the presence of a Location header, with the Location
header being added on an ad-hoc basis which could be simplified as it’s mostly duplication. Simplifying the logic of adding the header so that the default behaviour is applied for all non-special POST requests would also have effect of automating a 201 for any future resources.
After a little investigation it’s been determined that the Location
header is not used by Ghost-Admin, it was added for the original Backbone implementation of the admin area. If it’s not used anywhere else we could probably remove all of the logic around the Location
header and simply return 201
for all successful POST
requests.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (7 by maintainers)
Top GitHub Comments
I would advocate strongly for not returning a post URL in the location header in v2. If we keep it, the location should be for the Content API resource URI, rather than the “front-end” location.
@hbogaeus 200