REST API附件错误

编程入门 行业动态 更新时间:2024-10-12 20:27:11
本文介绍了REST API附件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在使用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": "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": "g87a2173.ngrok.io/content/attachments/e58bcefa-7060-464f-96ee-78d2795ec80f", "name": "audio.wav" } ] }

我收到400错误

{ "error": { "code": "BadArgument", "message": "Unknown attachment type" } }

用于这些测试的其余端点是

The rest endpoint used for these tests is smba.trafficmanager/apis/v3/conversations/29%3A1-Dl1xMx6G2qGya5O5BgTZJhc0fUKOiQLctt74CmwJ3PVJNgkocpf3LY626py9UIO/activities

API参考文档指出

附件可以是媒体文件(例如,音频,视频,图像,文件)或 一张丰富的卡

An attachment may be a media file (e.g., audio, video, image, file) or a rich card

那我在哪里错了?

谢谢

推荐答案

我使用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:

此处的示例代码: github/Microsoft/BotBuilder-Samples/tree/master/CSharp/cards-RichCards

更多推荐

REST API附件错误

本文发布于:2023-11-28 15:03:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642894.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:附件   错误   REST   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!