我试图在下面的一行中使用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
发布于 2022-05-20 08:21:13
我可以说您正在使用实用程序。有不同的语法。它期待的是一个哈希表类型值的标题。
@{<name> = <value>; [name = <value> ] ...}
如果您真的想让它在power shell中工作,请查看power的调用-WebRequest语法
当我用卷曲运行这个命令时,它起了作用,没有问题。
调整是,如果在windows中安装了git,可以将命令提示符设置为Git\mingw64 64\bin,然后执行curl命令。
https://stackoverflow.com/questions/72315426
复制相似问题