Handling no resource created in POST

Not applicable

In case of a search functionality, is it "fair" to use POST because search results are being created dynamically? If so, what HTTP error code be suitable in case search does not generate any results? Can "204" be used?

0 2 449
2 REPLIES 2

A search should be a GET. I think we can have a payload with GET with the search criteria. 204 No Content is applicable for GET, PUT & DELETE, hence you can send it if you use GET.

@Shailesh Bhaskaran ,

Adding on top of @Abhishek Subramanya , You are going to fetch search results (information) which already existed somewhere. I believe GET is more appropriate then POST.

For example, Google Custom Search API uses GET method & response with Status code 200 OK.

Short Answer, It should be GET & 200