or1ko's diary

日々を書きます

Invoke-RestMethodの文字化け対策

gooラボ 形態素解析APIを試してみる - pierre3のブログ

上のブログに記載されてました。
Invoke-RestMethodは諦めて、下記のようにInvoke-WebRequestを使うようです。

$res = Invoke-WebRequest -Method Post $url -Body $body
$con = [System.Text.Encoding]::Utf8.GetString([System.Text.Encoding]::GetEncoding("ISO-8859-1").GetBytes($res.Content))
#JSONの場合は下記のように変換する
ConvertFrom-Json $con