botframework - 将内联图片作为 MS Team Bot 发送时出现错误请求
问题描述
当我使用以下代码将附件作为 MS Teams Bot 的内联图片包含在内时,我收到了错误的请求(该代码在没有附件的情况下工作):
var message = Activity.CreateMessageActivity();
message.Text = "message here";
message.Attachments = new List<Attachment>();
var webClient = new WebClient();
byte[] imageBytes = webClient.DownloadData("https://img.icons8.com/windows/452/showing-small-size.png");
string url = "data:image/png;base64," + Convert.ToBase64String(imageBytes);
message.Attachments.Add(new Attachment
{
ContentType = "image/png",
ContentUrl = url
});
var conversationParameters = new ConversationParameters
{
IsGroup = true,
ChannelData = new TeamsChannelData
{
Channel = new ChannelInfo(outputChannelId),
},
Activity = (Activity)message
};
var response = await connectorClient.Conversations.CreateConversationAsync(conversationParameters);
我收到以下错误:
Microsoft.Bot.Schema.ErrorResponseException: Operation returned an invalid status code 'BadRequest'
at Microsoft.Bot.Connector.Conversations.CreateConversationWithHttpMessagesAsync
提前致谢!
解决方案
推荐阅读
- s4sdk - 无法使用 s4sdk 从本地系统获取数据
- html - 如何在 HTML 表格中通过 CSS 为 TD 单元格边框的所有 4 个边着色?
- python - Python:如何从另一个脚本终止脚本的功能
- excel - 使用具有非数值的 IF Then 函数进行分类
- java - 收集/计数到非空 Map 会引发 ClassCastException
- flutter - Build Runner 未在项目文件夹中运行
- sql - MS Access VBA 使用 SQL 和 Schema.ini 将 csv 导入新表 - 强制表的列名
- sql - 每组最多 3 个值
- java - 寻找使用动态 Hitbox 和图形创建对象的方法
- java - MongoClient 是抽象的,无法实例化