wizzkid
wizzkid

Reputation: 207

Is there a clean way to do a HTTP GET with many parameters?

So this is not a concrete problem I'm having with some code but rather an interesting scenario which I want to see how other people would solve it.

The scenario is as follows: Let's say you want to implement a GET request, but the server needs to know about some information to filter the results correctly. In almost all the cases you would add the information as query parameters in the URL, but this is where this scenario differs. The number of parameters for this request is a lot.

Now a couple of ideas that I have heard so far includes things like sending the parameters in the request body and using other the verbs like PUT and POST to get the data.

What would be the cleanest way of solving this scenario without diverging too far from REST standards?

Upvotes: 1

Views: 2371

Answers (1)

Jacck Mark
Jacck Mark

Reputation: 147

I would just send it with POST as a JSON object and then parse it on the server side. To get only needed data. This is pretty popular pattern to resolve problem when you are implementing GET with a lot of parameters and i've seen this a lot when using API's.

Here is also good answer (https://stackoverflow.com/a/31984477/9978135) to almost same question: Design RESTful query API with a long list of query parameters

Upvotes: 2

Related Questions