我的 API 调用适用于邮递员,但不适用于 curl,因为它无法读取查询参数

My API call works with postman but not with curl as it is not able to read a query parameter

我正在使用 REST API (POST),它类似于:

https://my.server.com/fooApp/rest/agent/<foo_id>/binaries?type=xxx&platform=LINUX

如您所见,此 API 有 2 个查询参数,并且还需要某些 json body 随请求一起发送。该请求还需要两个 headers - content-type 和一个自定义的身份验证令牌 header。当我通过 Postman 运行 这个请求时,它可以完美地工作但是当我 运行 使用 curl 时,我的服务器 returns 一个错误,“ 必需的字符串参数 ' platform' is not present”(只贴了摘录,省略了其他常见的东西)

以下是我尝试使用 curl 使用 API 的方式:

curl -d @myRequestBody.json -H 'Content-Type: application/json' -H 'Session-token: MyAuthToken' https://my.server.com/fooApp/rest/agent/<foo_id>/binaries?type=xxx&platform=LINUX

我错过了什么?我直接从 Ubuntu shell.

使用 curl 调用

如果您还用撇号将 url 括起来会怎样?

curl -d @myRequestBody.json -H 'Content-Type: application/json' -H 'Session-token: MyAuthToken' 'https://my.server.com/fooApp/rest/agent/<foo_id>/binaries?type=xxx&platform=LINUX'

shell 可能看到与号 (&) 并认为这是命令的结尾。