我正在尝试使用以下代码使用Graph API向MS团队发送消息。
List<Recipient> recipients = new List<Recipient>();
recipients.Add(new Recipient
{
EmailAddress = new EmailAddress
{
Address = "[email protected]"
}
});
// Create the message.
Message msg = new Message
{
Body = new ItemBody
{
Content = "Test message3",
ContentType = BodyType.Text,
},
ToRecipients = recipients
};
_graphServiceClient.Users["fe0bb333-3334c49-a3eb-25af61fed1db"].SendMail(msg, true).Request().PostAsync().Wait();
此代码不会在MS Team中发送消息,而是在电子邮件中发送该消息。
我正在关注文档https://docs.microsoft.com/en-us/graph/api/message-send?view=graph-rest-1.0并且正在使用Graph Explorer发送消息但不能正常工作。
请求机构
{“身体”:“Hello World”}
但是,我从Graph Explorer中得到以下错误:
{
"error": {
"code": "ErrorInvalidIdMalformed",
"message": "Id is malformed.",
"innerError": {
"request-id": "9cddabed-f886-4c89-be8b-7b5735ad957f",
"date": "2019-04-21T05:37:11"
}
}
}
今天,图中Microsoft团队的API仅支持向频道发送消息,而不是向用户发送消息(私人聊天)。正如您所看到的here,只列出了渠道运营。