0

我找不到足够的文档或工作示例。

从官方网站看来是可能的,我试过这个:

$Payload = { text:Hello; username:bot; channel:user}
Invoke-RestMethod -Uri https://mymattermost.com/hooks/%Bearer token% -Method Post 
-ContentType 'application/json' -Body (ConvertTo-Json $Payload

但总是得到同样的错误:

Invoke-RestMethod : {"id":"web.incoming_webhook.text.app_error","message":"No text
specified","detailed_error":"","request_id":"aaaaaaaaaaaaaaa","status_code":400}
At line:1 char:1
4

1 回答 1

1

好吧,您所要做的就是在@下添加用户名channels,它可以工作,如下所示:

> $Payload = @{ text="Hello"; username="bot"; channel="@user"}

> Invoke-RestMethod -Uri https://mymattermost.com/hooks/124twgvrq4tgw54e4 -Method Post 
  -ContentType 'application/json' -Body (ConvertTo-Json $Payload) -UseBasicParsing

这会成功的。注意:无论谁创建了 webhook,都将是分配给直接频道的用户

于 2020-03-27T13:44:37.707 回答