简体   繁体   English

如何使用Json URL请求为一个参数指定多个值?

[英]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.

相关问题 在 postman 测试中,当输入参数可以为空时,如何使用多个值之一断言响应值? - In postman tests, how can i assert the response values with one of multiple values when the input parameter can be empty? 如何使用JSON Extractor提取的多个值中的每个请求使用一个值 - How to use one value per request from the Multiple Values extracted using JSON Extractor 如何在Spring REST中接收多个参数值并以JSON格式返回数据? - How can I receive multiple parameter values and return data in JSON format in Spring REST? 如何在JSON请求标头中设置参数? - How can I set parameter in JSON request header? 如何在Java中使用带有多个相似参数的JSON请求/响应使用循环? - How can I use loop for JSON request/response with multiple similar parameters in Java? 我如何获取我的url请求的Json? - How can i get the Json of my url request? 如何将 JSON 字符串转换为 URL 参数(GET 请求)? - How can I convert a JSON string to URL parameters (GET request)? 如何解析URL请求中的JSON结果? - How I can parse JSON result from URL request? 如何使用 Z23EEEB4347BDD26BFC6B7EE9A3B7 在 json 中向 url 发送 postman 请求 - how can i send a postman request to a url in json with python 如何在API的url参数上使用通配符? - How can I use a wildcard on a url parameter to an API?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM