Rest API attachment error

妖精的绣舞 提交于 2019-12-13 15:37:10

问题


I've problems sending attachments through a Skype channel using the bot framework REST API.

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.

For example, if I send

{  
   "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"
        }
    ]
}

I get a 400 error

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

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

The API reference documentation states that

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

so where am I wrong?

Thank you


回答1:


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.

Anyway you may try to use AudioCard: I tested it (in C# code) and it's working on Skype:

Sample code here: https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/cards-RichCards



来源:https://stackoverflow.com/questions/44389904/rest-api-attachment-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!