我能够在PowerShell v5中使用JIRA REST API。然而,在PowerShell v3中,相同的代码会抛出以下错误:
WARNING: Remote Server Response: The 'Content-Type' header must be modified using the appropriate property or method.
源代码
$basicAuth = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($Username):$Password"))
$headers = @{
"Authorization" = $basicAuth
"Content-Type"="application/json"
}
$response = Invoke-RestMethod -Uri $requestUri -Method POST -Headers $headers -Body $body