这是我服务器上的api:
https://server/api/v1/products?filter[name]=foo
当我通过浏览器访问它时效果很好,并且它适用于以下两种方法:
$ cat /tmp/x
{"filter": {"name": "foo"}}
$ curl -X GET -H 'Accept: application/json' -k -s --negotiate -u : -H 'Content-Type: application/json' -d "@/tmp/x" https://server/api/v1/products
{"name": "foo", ...}
$ curl -X GET -H 'Accept: application/json' -k -s --negotiate -u : -d "filter[name]=foo" https://server/api/v1/products
{"name": "foo", ...}
现在我试图用:
$ curl -X GET -H 'Accept: application/json' -k -s --negotiate -u : https://server/api/v1/products?filter[name]=foo
$ echo $?
3
它失败,错误代码为3,代表"网址格式错误。语法不正确。"
如何在网址中指定查询字符串参数?
答案 0 :(得分:3)