Reputation: 28364
This is more of a best practice question, but some of you may have some insight on the possible repercussions here. Let's say I call:
GET /v1/items/
and no items are found.
Should I return:
Upvotes: 0
Views: 101
Reputation: 4877
Depends on how you want to handle the response. I would go for 200 with an empty array, indicating that the REST call succeeded but no matches found. This would be helpful for the layer that consumes the deerialized response.
If you are relying heavily on the HTTP status codes for downstream processing/error handling/error messages then 404 is fine. This is helpful if the request is often performed via a browser also. And also this would be a purist approach.
I do not see any added value for the third option.
Upvotes: 2