次のようなcurlでの処理をInvoke-WebRequestで実行したいと思っています。
curl --trace-ascii - -b cookies.txt -c cookies.txt -H 'Content-type: application/json' -H 'Accept: application/json' -X POST --user EMAIL:PASSWORD https://hogehoge
Invoke-WebReqestでは次のように記述しています。
$user = 'mail@hoge.com'
$pass = 'password'
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue ;
Accept = "application/json"
}
Invoke-WebRequest -Headers $Headers -Uri "https://hogehoge" -SessionVariable mySession -ContentType "application/json" -Method POST
これを実行すると次のようなエラーがでて実行できません。
Acceptヘッダの指定に問題がありそうですが、Acceptヘッダはどのように指定すればよいでしょうか?教えてください。
Invoke-WebRequest : The 'Accept' header must be modified using the appropriate property or method.