'should API return 404 status for api/object?filter=param?
Which HTTP status must be returned for api/object?filter=param if record not found? I see following variants:
- return 404
- return 200 and blank response, for example {}
I don not find conventions for ruby community. What is best practice?
Solution 1:[1]
You can go in the deep here: Proper REST response for empty table?
I think is correct to replay 200 with an empty object if you are calling an 'index' endpoint with search params
- request:
users?age=18 - response: code 200, body{}
But if you are calling a 'show' endpoint you should return 404
- request:
users/1 - response: code 404
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Patrick Barattin |
