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.
- 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.YorkshireKev– YorkshireKev2013-09-07 08:29:39 +00:00Commented 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).Aurélien Bénel– Aurélien Bénel2013-09-07 09:04:08 +00:00Commented Sep 7, 2013 at 9:04
- 1But 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.YorkshireKev– YorkshireKev2013-09-07 09:21:41 +00:00Commented 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.mariocatch– mariocatch2013-09-07 13:32:20 +00:00Commented 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.YorkshireKev– YorkshireKev2014-02-02 14:32:44 +00:00Commented Feb 2, 2014 at 14:32
Add a comment |
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. python-3.x), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you