相当于什么
curl -u username:password ...
Run Code Online (Sandbox Code Playgroud)
在PowerShell中Invoke-RestMethod
?我试过这个:
$securePwd = ConvertTo-SecureString "password" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($username, $securePwd)
Invoke-RestMethod -Credential $credential ...
Run Code Online (Sandbox Code Playgroud)
但它返回401,未经授权.
我是cURL的新手,刚刚安装了它,但它似乎只是做了它的感觉.我正在使用我从这里获得的64位版本:http://curl.haxx.se/latest.cgi?curl = win64-ss-spi,其中包含我在此处找到的安装说明:http://guides.instructure.com/m/4214/l/83393-how-do-i-install-and-use-curl-on-a-windows-machine.打开一个新的Powershell窗口我可以使用这样的简单GET请求:
curl http://localhost:3000
Run Code Online (Sandbox Code Playgroud)
但如果我运行POST
curl -d "hello world" http://localhost:3000
Run Code Online (Sandbox Code Playgroud)
它告诉我"Invoke-WebRequest:参数无法处理,因为参数名称'd'不明确.可能的匹配包括:-DisableKeepAlive -Debug."
我试图获得帮助
curl -h or curl --help
Run Code Online (Sandbox Code Playgroud)
给我"Invoke-WebRequest:缺少参数'Headers'的参数.指定'System.Collections.IDictionary'类型的参数,然后再试一次."
正如我所提到的,我是一个cURL新手,但它似乎很奇怪,它可以得到请求,但没有别的.我有什么想法我做错了吗?
Windows 7 64位Powershell版本4