[英]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. 我正在通过使用浏览器中的URL发送请求来与JSON API通信。 The Endpoint returns information about football matches. 端点返回有关足球比赛的信息。 It has a parameter named league_id which shows me information about a specific league. 它有一个名为League_id的参数,可向我显示有关特定联赛的信息。 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) 但是api仅向我显示leage_id参数之一的结果(League_id = 2)
is their a correct format i need to use for specifying multiple values for one parameter? 是我需要用于为一个参数指定多个值的正确格式吗?
If the API supports multiple values for a single query parameter they'll most likely be comma separated. 如果API支持单个查询参数的多个值,则很有可能将它们用逗号分隔。
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. 虽然,没有为单个参数提供多个值的“默认”支持,因为这是API提供程序需要专门编码的内容。
If you are able to do it, the docs for the API will say so. 如果您能够做到这一点,API的文档就会这样说。 They'll likely say something like " input is a comma separated list of IDs". 他们可能会说“输入是用逗号分隔的ID列表”之类的内容。
If they don't, then you're not able to do this and instead will need to make multiple calls. 如果他们不这样做,则您将无法执行此操作,而是需要拨打多个电话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.