Let's assume we have an Entity
{
"id": 1
"inProgress": true,
}
We have endpoints:
/api/v1/entities/
for fetching all entities,/api/v1/entities/1
for fetching entity with id = 1/api/v1/entities/in-progress
for fetching entity which is in progress. Note that there can be only one entity in progress.
Now, we can have 2 situations for /api/v1/entities/in-progress
:
- there is an entity in progress
- there is no entity in progress right now
Which status code should be returned for 2-nd case ?
404 - Not found
Looks ok, because there is no entity. Also, for 404 HTTP says The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.
200
Looks also ok, because request succeeded, but why should we return a null result?
204
Request succeeded but there is no result. Which also seems to be ok.
Which status code would you use and why?