Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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| ...}
like image 731
Juri Glass Avatar asked Oct 16 '09 14:10

Juri Glass


People also ask

How many parameters can a get request have?

The HTTP protocol does not limit the size of GET requests, but each browser and server have a data transfer limit. It is recommended to use an average of 512-1024 Kb or a maximum of 5 parameters to create one request.

Can we send query parameters in GET request?

To send query parameters in a GET request in JavaScript, we can pass a list of search query parameters using the URLSearchParams API.

How do you pass path parameters?

A URL can have several path parameters, each denoted with curly braces { } . Each path parameter must be substituted with an actual value when the client makes an API call. In OpenAPI, a path parameter is defined using in: path . The parameter name must be the same as specified in the path.


1 Answers

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.

like image 170
Darrel Miller Avatar answered Nov 12 '22 04:11

Darrel Miller