发送带有附件的消息时无法处理请求(Microsoft Teams Graph API)

时间:2020-02-27 08:21:04

标签: microsoft-graph-api

Code: BadRequest
Message: Failed to process request.
Inner error:
    AdditionalData:
    request-id: 768916ef-e040-42eb-aaa3-9ac5745f9224
    date: 2020-02-27T08:01:48
ClientRequestId: 768916ef-e040-42eb-aaa3-9ac5745f9224

嗨,在Teams频道上发送消息时,只要将文件附加到chatMessage上,我都会不断收到上述错误。无论如何,我正在使用“团队”路径。我的示例代码如下。

我错过了什么吗?

//  Base64 encoding of the file in data
            byte[] bytes = System.IO.File.ReadAllBytes(ContentUrl);
            string file = Convert.ToBase64String(bytes);



            // Make a channel chat message object
            var chatMessage = new ChatMessage()
            {
                Subject = null,
                Body = new ItemBody
                {
                    ContentType = BodyType.Html,
                    Content = constructedMsg
                },
                Attachments = new List<ChatMessageAttachment>()
                {
                    new ChatMessageAttachment
                    {
                        ContentType = "image/jpeg",
                        ContentUrl = file,
                        Content = null,
                        Name = null,
                        ThumbnailUrl = null
                    }
                }
            };

await _graphClient.Teams[teamId].Channels[channelId].Messages.Request().AddAsync(chatMessage);

0 个答案:

没有答案