如果您看到 Karate 将其编码为 %5B%5D,那实际上是正确的行为:https://stackoverflow.com/a/59977660/143475
您实际上可以在httpbin.org 上尝试此操作,并亲眼看看服务器是否能够正确解码它。如果您的服务器不能,则很可能是错误。
* url 'https://httpbin.org/anything'
* param include[] = 'tickers'
* method get
查看服务器响应:
1 > GET https://httpbin.org/anything?include%5B%5D=tickers
1 > Host: httpbin.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.6)
1 > Accept-Encoding: gzip,deflate
17:17:10.925 [main] DEBUG com.intuit.karate - response time in milliseconds: 1528
1 < 200
1 < Date: Tue, 07 Feb 2023 11:47:10 GMT
1 < Content-Type: application/json
1 < Content-Length: 436
1 < Connection: keep-alive
1 < Server: gunicorn/19.9.0
1 < Access-Control-Allow-Origin: *
1 < Access-Control-Allow-Credentials: true
{
"args": {
"include[]": "tickers"
},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept-Encoding": "gzip,deflate",
"Host": "httpbin.org",
"User-Agent": "Apache-HttpClient/4.5.14 (Java/17.0.6)",
"X-Amzn-Trace-Id": "Root=1-63e23a3e-4004ea8e65dba95003ec150e"
},
"json": null,
"method": "GET",
"url": "https://httpbin.org/anything?include[]=tickers"
}
那就是说您可以将所有内容移动到 URL:
* url `https://httpbin.org/anything?include[]=tickers`
* method get
如果你仍然需要参数化,你可以看:https://stackoverflow.com/a/75061809/143475