首页 > 解决方案 > 如何将带有标头授权和表单的 curl POST 转换为 PowerShell v3.0

问题描述

我有以下 curl 命令,我想将其转换为 PowerShell(PowerShell v3.0):

curl -s -k -H 'Authorization: api_key 1234567890' -F upload_file=@"C:\path\to\file" -X POST "https://my.url.com/submit"

到目前为止我所拥有的:

$Body= @{ "upload_file" = "C:\path\to\file" };
$Headers = @{ "Authorization" = "api_key 1234567890" };
$Uri = "https://my.url.com/submit"

Invoke-WebRequest -Method Post -Uri $Uri -H $Headers -Body $Body

我认为表单参数是问题所在。

提前致谢。

标签: powershellpowershell-3.0

解决方案


推荐阅读