Juri Glass
Juri Glass

Reputation: 91543

Best way to submit many (equally named) parameters in GET/REST

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| ...}

Upvotes: 6

Views: 1294

Answers (2)

SerialSeb
SerialSeb

Reputation: 6766

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.

Upvotes: 2

Darrel Miller
Darrel Miller

Reputation: 142024

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.

Upvotes: 8

Related Questions