首页 > 解决方案 > 在 Microsoft Teams webhook 消息中附加 Sharepoint 文件

问题描述

我有一个文件位于 Teams 的 Sharepoint 上以及与我在 Microsoft Teams 中的频道对应的文件夹中。

例如团队Banana频道ripe,所以我的文件在https://whatever.sharepoint.com/Banana/ripe

我想以编程方式将此文件与消息共享到频道以获得此结果:

截屏

我通过转到Files选项卡,单击文件,然后在团队客户端中收到上述消息Start conversation

我想使用 webhook 共享此文件。

不幸的是,我找不到任何关于MessageCardwebhook 似乎使用的有效负载可以让我执行上述操作的任何内容。

我尝试attachments像这样将部分机器人引用添加到消息中,但没有成功:

POST https://outlook.office.com/webhook/whateverelsehere HTTP/1.1
Host: outlook.office.com
Content: application/json
Content-Length: 401

{
  "@type": "MessageCard",
  "text":"This is a message3",
  "attachments": [{
    "contentType": "application/vnd.microsoft.teams.card.file.info",
    "contentUrl": "https://wherever.sharepoint.com/sites/feed-support/Banana/ripe/test.txt",
    "name": "text.txt",
    "content": {
      "uniqueId": "df90889f-e8a7-452a-8795-972be16fac6f",
      "fileType": "txt",
    }
  }]
}

标签: sharepointmicrosoft-teams

解决方案


目前无法使用 webhook 发送文件。webhook 中的文件支持是我们正在努力的工作,但我们没有针对它的 ETA。到目前为止,发送文件的唯一方法是使用 Bots。


推荐阅读