The best way to send many (equally named) parameters to GET / REST

For the REST interface:

What is the best way to allow a client to set many similarly named parameters in a GET?

For example, if a customer must specify several possible colors

www.example.com/products/{color=green|color=yellow|color=white| ...} 
+6
rest
source share
2 answers

Something like this would be fine:

 GET http://www.example.com/products?colors=green,yellow,white 

Despite popular belief, there is no REST restriction that says you should not use query string parameters.

+8
source share

Given that browsers consider the / x -form-urlencoded application and the query equivalent, and given that multiple values ​​can be provided for the same name, you can simply do color = red & color = green & color &. blue

If your selection structure handles this correctly, this should be fine.

+2
source share

All Articles