Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Re-reading your question, I think you might be looking for how to do a search/filter with many parameters? For this you could post to a search resource and return a link to the results resource. Of course you could just respond with the results but some would say that's less restful. Commented Sep 7, 2013 at 8:29
  • Please never use POST if you don't change data. One of the advantages of REST is to make explicit that GET methods are "safe" (and for example to cache their result). Commented Sep 7, 2013 at 9:04
  • 1
    But POST is for sending data to a resource which can then create a new resource, which in this case would be the results resource. So I believe the use of post here is correct. The downside to this is that a client would have to make a second (get) request to retrieve the results. It also makes the backend more complex which is why some would just take a pragmatic approach and simply return the results. I agree that doing so is not restful in any pure sense. Commented Sep 7, 2013 at 9:21
  • @YorkshireKev, correct - I'm using this for searching/filtering, not creation. I've seen the POST vs GET debate on obtaining search results over and over again, and unfortunately we have the same debate with my colleagues... so this won't be acceptable for my team. I appreciate the idea though - still looking for a good pattern on using GET here instead. Commented Sep 7, 2013 at 13:32
  • One alternative instead of passing in lots of query parameters is to have a set of pre-defined views and select one of those via a single query parameter. e.g. ?view=summary ?view=all ?view=somethingelse. This would be similar to how database views can be used so simplify select statements. Of course how useful this approach would be will depend on how many different query combinations your api needs to support. I've used this approach to good effect in the past where I use a view plus a small number of additional 'filter' query parameters. Commented Feb 2, 2014 at 14:32