question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent response codes for "resource created" responses

See original GitHub issue

We 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/ returns 201
  • POST /webhooks/ returns 201
  • POST /subscribers/ returns 200
  • POST /invites/ returns 200

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:closed
  • Created 6 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ErisDScommented, Sep 20, 2018

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.

1reaction
kirrg001commented, Feb 15, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

A Complete Guide and List of HTTP Status Codes
A complete list of HTTP status codes with explaination of what they are, why they occur and what you can do to fix...
Read more >
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >
HTTP response code for POST when resource already exists
The 409 (Conflict) status code indicates that the request could not be completed due to a conflict with the current state of the...
Read more >
HTTP Status Codes - REST API Tutorial
HTTP status codes and how to use them in RESTful API or Web Services. ... General status code. Most common code used to...
Read more >
Why ALL APIs are inconsistent? - Hanami Mastery
One of the most common problems in web applications, is to update the application state based on the business rules. How it's possible,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found