404 vs 204
Closed this issue · 1 comments
Hi Mark,
Sorry if log this as issue because it isn't, but 140 chars on twitter won't be enough for me to ask my question.
I'm not an expert in rest but I have always been under the impression that if the system doesn't find a resource given an id (resource doesnt exist in datasource) then you should return a 404. SimpleWeb doesn't have a Status.NotFound but has Status.NoContent (204).
Could you share your wisdom behind which code should be returned for the scenario mentioned above, or any other you may have?
Many Thanks
Yeah, the Status.Xyz members are non-exhaustive, and I haven't got round to 404 yet. Which is odd. Do feel free to fill them out and send a pull request :)
You can also just return 404; from the method. There's an implicit Int32 -> Status conversion.
204 No Content is for when what you've asked for is valid but the collection is empty. So a direct GET for a resource giving its identifier in the URI should return 404 if the identifier doesn't match a resource, but a query for multiple resources that finds no records should return 204, as in, the query was valid and ran but it didn't find any matches. 204 would also be appropriate for something like /customers/42/orders, where customer with id 42 exists but doesn't have any associated orders.
Hope that helps.