Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

No matches returns a 400 - Bad request error #70

Closed
jimcue opened this issue Oct 22, 2017 · 4 comments
Closed

No matches returns a 400 - Bad request error #70

jimcue opened this issue Oct 22, 2017 · 4 comments

Comments

@jimcue
Copy link

jimcue commented Oct 22, 2017

A well-formed request that returns no results will get a 400 HTTP code (Bad request) error response.

With no item with id>100 the request http://example.com/json/articles?filter[id]=>100 gets:

{
    "errors": {
        "details": "Bad request: There were no results based upon your criteria!",
        "status": 400,
        "title": "Bad Request"
    }
}

Would it not make sense to get a 200 HTTP response with an empty list (or null for specific-item requests) as mentioned in the JSON API specs?

HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
  "links": {
    "self": "http://example.com/articles"
  },
  "data": []
}
@luminarious
Copy link

204 No Content would be perfect.

@rwd
Copy link

rwd commented Apr 10, 2018

As mentioned by @jimcue the JSON API spec states that the response code in this scenario MUST be 200 OK: http://jsonapi.org/format/#fetching-resources-responses

d-m- added a commit to d-m-/jsonapi that referenced this issue Apr 12, 2018
xiaohutai added a commit that referenced this issue Apr 23, 2018
Return empty lists with status 200 instead of 400 - Fix for issue #70
@xiaohutai
Copy link
Owner

Fixed via #80.
Will be available in a new release later today (or tomorrow).

@xiaohutai
Copy link
Owner

xiaohutai commented Apr 23, 2018

Should be fixed in v3.2.0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants