gpt4 book ai didi

windows - Windows 的 curl 命令语法

转载 作者:可可西里 更新时间:2023-11-01 11:25:29 27 4
gpt4 key购买 nike

我有以下命令,它在 Linux 上运行良好,但在 Windows 上运行不佳。我找不到任何有关 Windows curl 语法的文档。我尝试了引号 .. 但仍然无法正常工作。任何人都可以帮助我使用这个命令,以便我可以在 Windows 上使用它(我已经在 c 驱动器中安装了 curl.exe)

curl -X POST -H "Content-Type: application/json" -H "X-Cachet-Token: secret" http://somegoodserver/api/v1/incidents -d '{"name":"Test","message":"Test message","status":"1"}'

我得到的错误是:

"status":400,"title":"Bad Request","detail":"The request cannot be fulfilled due to bad syntax.","meta": {"details":["The name format is invalid.","The status format is invalid.","The message format is invalid."]}}]}

最佳答案

Windows 要求每行末尾有一个 ^,双引号而不是单引号(json 括号内除外),并且在 json 数据中,所有双引号都必须转义。

这是在 Win10 和 WinXP 命令提示符下工作的 GET 和 POST 示例:

curl -X GET ^
-H "authorization: Basic [your authentication string, if needed]" ^
-H "cache-control: no-cache" ^
-H "content-type: application/json" ^
-H "x-forte-auth-organization-id: org_333251" ^
"https://sandbox.forte.net/api/v3/organizations/org_333251/locations/loc_191620/customers/"


curl -X POST ^
-H "authorization: Basic [your authentication string, if needed]" ^
-H "cache-control: no-cache" ^
-H "content-type: application/json" ^
-H "x-forte-auth-organization-id: org_333251" ^
-d "{ \"action\": \"sale\", \"authorization_amount\": 16.99, \"billing_address\": { \"first_name\": \"Paul\", \"last_name\": \"Hurst\" }, \"card\": { \"card_type\": \"visa\", \"name_on_card\": \"Forte James\", \"account_number\": \"4111111111111111\", \"expire_month\": \"12\", \"expire_year\": \"2020\", \"card_verification_value\": \"123\" } }" ^
"https://sandbox.forte.net/api/v3/organizations/org_333251/locations/loc_191620/transactions" ^

关于windows - Windows 的 curl 命令语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39397462/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com