kuk*_*_94 13 powershell curl apigee
我在Apigee中有一个API代理,它使用API密钥进行身份验证.我使用cURL使用我的HTTP请求标头传递密钥,使用以下命令:
curl -v -H "apikey: my_key" http://api_org-test.apigee.net/v1/helloapikey
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Invoke-WebRequest : Cannot bind parameter 'Headers'. Cannot convert the
"apikey: my_key" value of type "System.String" to
type "System.Collections.IDictionary".
Run Code Online (Sandbox Code Playgroud)
当我修改我的策略以查找查询参数而不是标题中的键时,它可以正常工作.我在这里错过了什么吗?
Mar*_*ndl 24
试试这个:
curl -v -H @{'apikey' = 'my_key'} http://api_org-test.apigee.net/v1/helloapikey
Run Code Online (Sandbox Code Playgroud)
注意:
curl是Invoke-WebRequestcmdlet 的别名:
Get-Alias curl
Run Code Online (Sandbox Code Playgroud)
输出:
CommandType Name
----------- ----
Alias curl -> Invoke-WebRequest
Run Code Online (Sandbox Code Playgroud)
以上答案都不适合我(我收到错误 - parse error near })。
这有效:
curl -X GET \
'http://api_org-test.apigee.net/v1/helloapikey' \
-H 'apikey: my_key'
Run Code Online (Sandbox Code Playgroud)
您可以安装curl:https : //stackoverflow.com/a/16216825/3013633
通过执行以下命令来删除现有的curl别名:
Remove-item alias:curl
然后您的命令将起作用:
curl -v -H "apikey: my_key" http://api_org-test.apigee.net/v1/helloapikey
| 归档时间: |
|
| 查看次数: |
26912 次 |
| 最近记录: |