PSSlack icon indicating copy to clipboard operation
PSSlack copied to clipboard

Can't send non-Latin text with Send-SlackMessage

Open moigagoo opened this issue 5 years ago • 1 comments

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.

moigagoo avatar Dec 17 '19 11:12 moigagoo

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).

tats-u avatar Jan 08 '20 17:01 tats-u