0

I'm in the initial stages of planning a REST api. I'm only interested in the read aspects of it for now. I'm having trouble with filters. As a hypothetical, this api is designed to serve "foo" products. Each foo product can have one or more "bar" items, and one or more "baz" items. The combination of foo/bar/baz is what makes the final product (and url) distinct, and is what I'm looking for. The url must be bookmarkable, and able to recreate the final configured product.

I considered this answer, but while they suggest using query parameters as filters, it doesn't really address how to do so when more than one filter is needed. Say, for example, I needed foo item "1", with bar items "1,3,4" and baz items "2,5". What is the most proper construction for this sort of request? I'm thinking 'foo/1/bar/1,3,4/baz/2,5' is problematic. Is it perhaps 'foo/1/bar/baz?bar=1,3,4&baz=2,5'? 'foo/1?bar=1,3,4&baz=2,5'? Do singletons all get to be part of the url, where multiples are relegated to the query parameters?

1
  • Isn't it possible to have an unique id for each possible combination? Commented Jul 24, 2015 at 21:08

1 Answer 1

0

You should avoid using comma in your URL as it's reserved word, so you might get into the trouble even though it might work well on your server.

I would try with %2C which is URL encoded value for comma.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the response. I think I'm going to have to end up using query parameters to do what I'm trying to do, with the url encoded comma as you suggest.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.