Hi
For a REST interface:
What is the best way to allow the client to set many equally named parameters in a GET?
For example if the client should specify multiple possible colors
www.example.com/products/{color=green|color=yellow|color=white| ...}
Hi
For a REST interface:
What is the best way to allow the client to set many equally named parameters in a GET?
For example if the client should specify multiple possible colors
www.example.com/products/{color=green|color=yellow|color=white| ...}
Something like this would be fine:
GET http://www.example.com/products?colors=green,yellow,white
Despite popular opinion, there is no REST constraint that says you should not use query string parameters.
if all you need is a simple query by a single parameter then I'd go with Darrel's suggestion, if your query can become more complex, you can consider SQL like query params:
GET http://www.example.com/products?query={colors IN (green,yellow,white) AND size='small')}
Considering browsers consider the application/x-form-urlencoded and the querystring equivalent, and considering several values can be provided for the same name, you can simply do color=red&color=green&color&blue.
Provided your framework of choice handles this correctly, this should be jsut fine.
For some queries, we could encounter URI length limitations. I'm curious how people have dealt with that in a RESTful fashion.
I was considering POST/PUTing a Query object with a document containing a large batch of query data, and getting the ID of that resource, then doing a GET operation, passing the query's ID.
Seems a bit less than optimal, though. Two queries, just to be RESTful.