如何将此请求正文添加到我的 CURL 请求中

How to add this request body to my CURL request

我有一个 post 使用 CURL 提交的请求:

curl -L -X POST https://pubsub.googleapis.com/v1/projects/projectName/subscriptions/subName:pull?key=redactedAPIKey

我需要向请求中添加请求正文,如下所示:

‘{“returnImmediately”: true, “maxMessages”: 1}’

实现此目的的正确语法是什么?

我试过:

curl -L -X POST https://pubsub.googleapis.com/v1/projects/projectName/subscriptions/subName:pull?key=redactedAPIKey -H 'Content-Type: application/json' -d ‘{“returnImmediately”: true, “maxMessages”: 1}’

失败了。

试试这个

curl -XPOST -H "Content-type: application/json" -d '{'returnImmediately': true, maxMessages: 1}' 'urlHere'