我正在嘗試使用帶有以下行的 curl 命令并遇到錯誤。
curl -H "Content-Type: application/json" -X POST -d '{"name": "ggg","address":"gemany" }' urlplaceholder
Invoke-WebRequest : Cannot bind parameter 'Headers'. Cannot convert the "Content-Type: application/json" value of type "System.String" to type "System.Collections.IDictionary".
At line:1 char:9
curl -H "Content-Type: application/json" -X POST -d '{"name": "ggg"," ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
uj5u.com熱心網友回復:
我可以說您使用的是 Microsoft Power shell 實用程式。它具有不同的語法。它期望標題的哈希表型別值
@{<name> = <value>; [name = <value> ] ...}
如果您真的希望它在 power shell 中作業,請通過 power shell 的 Invoke-WebRequest 語法
當我在 curl 中運行此命令時,它可以正常作業,沒有問題。
一個調整是,如果你在 windows 中安裝了 git,你可以將命令提示符設定為 Git\mingw64\bin,然后從那里執行你的 curl 命令
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/479752.html
標籤:卷曲
