[英]cURL command doesn't work from terminal prompt
按照 /campaigns 下的文档,我尝试使用我的 api-key 示例。
我在 Mac(bash shell)上使用终端窗口。
curl -X POST https://api.mailerlite.com/api/v2/campaigns \
-d '{
"subject": "Regular campaign subject",
"segments": 1291259,
"type": "regular"
}' \
-H "Content-Type: application/json" \
-H "X-MailerLite-ApiKey: <api-key>" \
我将整个内容粘贴到提示中,即使这似乎不是正确的方法。
部分命令被理解,然后部分通过,shell 会询问这个Display all 114 possibilities question
:
~/: curl -X POST https://api.mailerlite.com/api/v2/campaigns \
> -d '{
>
Display all 114 possibilities? (y or n)
后跟目录列表,后跟:
> campaign subject",
> "segments": 1291259,
> "type": "regular"
> }' \
> -H "Content-Type: application/json" \
> -H "X-MailerLite-ApiKey: <api-key>" \
>
{"error":{"code":400,"message":"Campaign type is missing"}}~/:
从 bash shell 发出多行 cURL 命令的正确方法是什么?
用空格替换制表符,并删除最后一个反斜杠,然后它应该可以正常工作。
curl -X POST https://api.mailerlite.com/api/v2/campaigns \
-d '{
"subject": "Regular campaign subject",
"segments": 1291259,
"type": "regular"
}' \
-H "Content-Type: application/json" \
-H "X-MailerLite-ApiKey: <api-key>"
它给了我以下输出:
$ curl -X POST https://api.mailerlite.com/api/v2/campaigns \
> -d '{
> "subject": "Regular campaign subject",
> "segments": 1291259,
> "type": "regular"
> }' \
> -H "Content-Type: application/json" \
> -H "X-MailerLite-ApiKey: <api-key>"
{"campaign_type":"regular","date":"2020-10-06 19:21:47","account_id":<id>,"id":<id>,"mail_id":<id>,"options":{"current_step":"step3","send_type":"regular","campaign_type":"regular","date":"2020-10-06 19:21:47"}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.