vendredi 30 décembre 2016

REST API - What to return when search criteria (queryParams) doesn't yield any results

I am designing a REST API and throughout the API we have used HTTP Not found / 404 when an object/resource we are trying to access doesn't exist.

Ex: http://host/someobject/1

But the current one scenario is little different. I have the URI which searches the data with query parameters.

Ex: http://host/someObject/find?param1=param1value&param2=param2value

The query parameters are optional but at least one criteria must be provided for successful request. I am currently returning empty list when search result is empty assuming the URI exists but data not present at the moment.

Can any one shed some light on this scenario ? Should I return empty array with Status code 200 or something else ?




Aucun commentaire:

Enregistrer un commentaire