Microsoft graph api 带有jpeg图像的Microsoft Graph API附件失败
我已经使用Micorosoft.Graph.GraphServiceClient(版本3.14)成功地向团队频道发布了一条消息。然而,我想包括一个图像附件(通过聊天信息附件)。根据文档,为了做到这一点,我应该将ChatMessageAttachment.ContentType设置为“image/jpeg”,并将ContentUrl设置为图像文件的base64字符串表示形式。这是我的密码:Microsoft graph api 带有jpeg图像的Microsoft Graph API附件失败,microsoft-graph-api,microsoft-teams,microsoft-graph-teams,Microsoft Graph Api,Microsoft Teams,Microsoft Graph Teams,我已经使用Micorosoft.Graph.GraphServiceClient(版本3.14)成功地向团队频道发布了一条消息。然而,我想包括一个图像附件(通过聊天信息附件)。根据文档,为了做到这一点,我应该将ChatMessageAttachment.ContentType设置为“image/jpeg”,并将ContentUrl设置为图像文件的base64字符串表示形式。这是我的密码: var chatMessage = new ChatMessage { Subject = subj
var chatMessage = new ChatMessage
{
Subject = subject,
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = message // Including <attachment id="<imageId>"></attachment>
}
};
chatMessage.Attachments = new List<ChatMessageAttachment>
{
new ChatMessageAttachment
{
Id = imageId,
ContentType = "image/jpeg",
ContentUrl = base64String,
Name = "HunnySuckle.jpg"
}
};
var res = await graphClient.Teams[teamId].Channels[channelId].Messages
.Request()
.AddAsync(chatMessage);
这是文档的摘录()
contentType。image/:具有图像类型的图像类型
指定的示例:image/png、image/jpeg、image/gif。填充
contentUrl字段,文件的base64编码为data:format
然而,我不确定“in data:format”是什么意思——也许这就是为什么它不起作用的关键
我在网上搜索发现的这个错误的另一个参考是在这个页面上:我想这和我的问题是一样的(但遗憾的是没有答案)
{
"error": {
"code": "InternalServerError",
"message": "Failed to process request.",
"innerError": {
"date": "2020-09-18T20:39:46",
"request-id": "44143c44-1c48-4a90-9bb5-20a3ba1b9905",
"client-request-id": "44143c44-1c48-4a90-9bb5-20a3ba1b9905"
}
}
}