使用列表查询参数的REST GET调用在POSTMAN中不起作用

问题描述

调用一个接受List作为查询参数的REST API。

将查询参数传递为:q="Listkey":["listvalue1","Listvalue2"]

但是失败,并显示400错误请求:
http://localhost:9097/api?q={"caseList":["testlist1"]}

但是通过查询参数工作如下:
q="Listkey":%5B"listvalue1","Listvalue2"%5D

http://localhost:9097/api?q={"caseList":%5B"testlist1"%5D}

我想知道为什么它不能与[ ]括号一起使用?

http://localhost:9097/api?q={"caseList":["testlist1"]}

请向我建议发送List查询参数的最佳做法。
谢谢

解决方法

],因为它正在被编码为%5D https://www.urlencoder.org/

我相信你会通过阅读这篇文章得到答案 Is array syntax using square brackets in URL query strings valid?

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...