问题描述
我在使用bot框架REST API通过Skype频道发送附件时遇到问题.
I've problems sending attachments through a Skype channel using the bot framework REST API.
我能够使用这样的json消息正确发送图像:
I'm able to correctly send images using a json message like this:
{
"type":"message",
"timestamp":"2017-05-22T11:31:36.2281894Z",
"from":{
"name":"MyBot"
},
"recipient":{
"id":"29:1-Dl1xMx6G2qGya5O5BgTZJhc0fUKOiQLctt74CmwJ3PVJNgkocpf3LY626py9UIO"
},
"text":"It works!",
"attachments": [
{
"contentType": "image/jpg",
"contentUrl": "https://g87a2173.ngrok.io/content/attachments/65f2be10-e61e-424e-9ea1-e05f1002fd19",
"name": "image.jpg"
}
]
}
但是,如果我发送的图像类型不是图像,则出现错误.
But if I send files with any content type other than image I have an error.
例如,如果我发送
{
"type":"message",
"timestamp":"2017-05-22T11:31:36.2281894Z",
"from":{
"name":"MyBot"
},
"recipient":{
"id":"29:1-Dl1xMx6G2qGya5O5BgTZJhc0fUKOiQLctt74CmwJ3PVJNgkocpf3LY626py9UIO"
},
"text":"Not working!",
"attachments": [
{
"contentType": "audio/wav",
"contentUrl": "https://g87a2173.ngrok.io/content/attachments/e58bcefa-7060-464f-96ee-78d2795ec80f",
"name": "audio.wav"
}
]
}
我收到400错误
{
"error": {
"code": "BadArgument",
"message": "Unknown attachment type"
}
}
API参考文档指出
那我在哪里错了?
谢谢
推荐答案
我使用C#代码尝试了相同的操作,并得出了相同的结论:在Skype Channel上,我们为此出现了Unknown attachment type
异常.在模拟器和Slack上工作(获得了下载wav文件的链接)
I tried the same with C# code and got the same conclusion: on Skype Channel, we got an Unknown attachment type
exception for this.Working on emulator and Slack (got a link to download the wav file)
必须有一个频道限制,或者是一个错误.
There must be a channel limitation yes, or a bug.
无论如何,您都可以尝试使用AudioCard
:我已经在C#代码中对其进行了测试,并且可以在Skype上运行:
Anyway you may try to use AudioCard
: I tested it (in C# code) and it's working on Skype:
此处的示例代码: https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/cards-RichCards
这篇关于REST API附件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!