jonny b
jonny b

Reputation: 75

How can i use a Json URL request to specify multiple values for one parameter?

I am communicating with a JSON API by sending requests using URL'sin the browser. The Endpoint returns information about football matches. It has a parameter named league_id which shows me information about a specific league. Example:

https://football.domain/api/?action=league_id=1

However i want to get results for more then one league in one request

I have tried :

https://football.domain/api/?action=league_id=1&league_id=2

However the api only shows me the results for one of the the leage_id parameters (League_id=2)

is their a correct format i need to use for specifying multiple values for one parameter?

Upvotes: 0

Views: 2212

Answers (1)

Matt
Matt

Reputation: 88

If the API supports multiple values for a single query parameter they'll most likely be comma separated.

Eg,

...ID=1,2,3...

Although, there is no "default" support for supplying multiple values for a single parameter as this is something the API provider needs to specifically encode.

If you are able to do it, the docs for the API will say so. They'll likely say something like " input is a comma separated list of IDs".

If they don't, then you're not able to do this and instead will need to make multiple calls.

Upvotes: 1

Related Questions