PSSlack
PSSlack copied to clipboard
Can't send non-Latin text with Send-SlackMessage
Trying to send a message with Cyrillic characters. All characters are replaced with ? in Slack.
Apparently, this is because the default encoding in PowerShell Core nowadays is UTF-8, but the module encodes the text with iso-8859-1.
https://github.com/RamblingCookieMonster/PSSlack/blob/b8ff0bd60aebfb270afd1973928ed8fcc137153a/PSSlack/Public/Send-SlackMessage.ps1#L376
Appending the option -ContentType "application/json; charset=utf-8"
may fix this issue.
Invoke-RestMethod -Method Post -Uri "https://hooks.slack.com/services/[snip]" -Body "{'text': 'Test message / テストメッセージ / Тестовое сообщение'}" -ContentType "application/json; charset=utf-8"
worked in PowerShell 6 in Ubuntu and 5 in Windows 10 (chcp 932).