在curl中的get请求中发送多个请求参数,只有单个参数

时间:2017-04-12 18:19:57

标签: unix curl get

我正在尝试通过命令行向我的api发出curl get请求。

curl http://localhost:8080/getList?id=100&mrp=50&discount=0

但是当我在api中记录请求时,我得到了:

&{GET /getList?id=100 HTTP/1.1 1 1  which means that only id is being sent through the request. I don't understand why it is happening.

1 个答案:

答案 0 :(得分:3)

当您运行curl命令时,多个请求参数由&分隔,unix会将&视为符号,以便在后台执行上一个命令。其后跟随它的其他命令将被视为单独的命令

在发送请求时将引号包裹在引号中

curl "http://localhost:8080/getList?id=100&mrp=50&discount=0"