LoginSignup
3
6

More than 5 years have passed since last update.

PowerShellでMattermostにログインしてポストする

Posted at

環境

PowerShell 5.1.14409.1012
Mattermost 4.8.0

PowerShellのスクリプト


$loginResponse = Invoke-WebRequest -Uri "http://localhost:8065/api/v4/users/login" -Method POST -Body '{"login_id":"yourID","password":"yourPassword"}'
$token = $loginResponse.Headers.Token
$utf8PostBody = [System.Text.Encoding]::UTF8.GetBytes('{"channel_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","message":"出社!"}')
Invoke-WebRequest -Uri "http://localhost:8065/api/v4/posts" -Method POST -Body $utf8PostBody -Headers @{"Authorization" = "Bearer $token"}
  • http://localhost:8065 :仮のMattermostサーバのパス。
  • channel_id :WebGUIのチャンネル名をクリックし、情報を表示するを選択し確認する。
  • [System.Text.Encoding]::UTF8.GetBytes() messageに全角文字を指定したさいに文字化けさせないため記述。
3
6
0

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
3
6