【发布时间】:2017-12-12 22:35:10
【问题描述】:
将一个非常简单的 Plaid API curl 数据请求转换为一个 powershell invoke-webrequest
什么有效:
curl -X POST https://tartan.plaid.com/balance \
-d client_id=client-id-value \
-d secret=secret-value \
-d access_token=access-token-value
我在 Powershell 中的尝试失败
#test powershell api call
$hash = @{ client_id = "client-id-value";
secret = "secret-value"
access_token = "access-token-value"
}
$JSON = $hash | convertto-json
#Invoke-WebRequest -uri "https://tartan.plaid.com/balance" -Method POST -Body $JSON
这会返回格子错误 1100(缺少客户端 ID),因此我知道某些 API 功能正在运行,但它没有正确解析输入数据。
我最大的误解是如何将“curl -data”值转换为正确的 Powershell 参数。
这是一个标题值,正文值吗?等等。
【问题讨论】:
-
跳过
convertto-json步骤 -
更改为以下内容似乎有效,但我知道我的访问令牌已过期。
$post_values = @{client_id='value';secret='value2';access_token='value3'} Invoke-WebRequest -Uri https://tartan.plaid.com/balance -Method POST -Body $post_values
标签: json powershell curl