I'm wondering how to manage empty results returned by search queries in a REST web-service :I there was a query like my_ressource_collection/{id} and the resource didn't exists i would return 404 - Not FoundBut, if my URI is more like a search query like : my_ressource_collection/?fromDate={fromDate}&toDate={toDate}&filter1={filter1}&page={page} : Does the same logic applies ?If no results matchs to the perametters, do I have to return a 404 status ?
What HTTP status using for REST search query which returns nos results
rest;web services;api design
I think in the most cases the most useful reaction would be to return a regular answer (HTTP 200) and send empty data.For example if you are returning JSON you could send{}Another good option may be the HTTP Code '204 - No Content'.The 4xx codes describe a client failure, so the 404 code wouldn't be a good idea, because it's a valid request, even if there are no matching data.