LoginSignup
1
0

More than 1 year has passed since last update.

Windows からのとりあえず post

Posted at

curl 入れないといけないとかめんどい、とりあえずの場合は powershell だけで何とかしたい、というのが目的。

cat -Encoding UTF8 'post.json' | Out-File -Encoding DEFAULT 'test.txt'
$w = Invoke-WebRequest -Method Post -InFile 'test.txt' -ContentType 'application/json' http://***
echo $w.RawContent |Out-File 'response.txt'

utf8にBOMがある場合そのまま投げると Invoke-WebRequest で失敗する(↓メッセージ)。一行目はut8をshift-jisに変換してこれを防ぐ。

BOMなしutf8を作るのはちょっとめんどいが一応できるらしい。https://qiita.com/yaju/items/b519ff54a6906338442c

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0