【问题标题】:Images hosted in share point aren't displaying when posted to team via webhook通过 webhook 发布到团队时,sharepoint 中托管的图像不显示
【发布时间】:2020-06-18 12:37:29
【问题描述】:

我正在尝试将我们的一些报告从 Slack 迁移到 Microsoft Teams。 我们目前正在通过 Azure 函数将图像和 csv 文件发布到 slack。

早些时候,我注意到我无法直接发布图片,但我可以在卡片中提及他们的 URL,然后会显示预览并单击它应该会将我带到实际图片。 我开始认为这将非常简单。然后我开始使用 webhooks 选项。唯一的问题是它只支持两种类型的卡片,我几乎无法控制图像大小和其他属性。如果我要使用自适应卡(任何其他卡),那么我将不得不放弃 webhook 并使用我已经开始使用的 Graph API。

然后我开始注意到图像消失了,因为它们不再显示了。我相信这可能是本答案中提到的共享点/团队之间的身份验证问题- Adaptive cards for MS Teams - images displaying in web interface but not desktop application

浏览器中的团队显示图像,但桌面应用程序不显示。此外,它们也没有显示在我的团队移动应用中。

我已经修改了我现有的应用程序,将图像/文件的副本(无论它创建什么)发送到 sharepoint 内的文件夹,该文件夹是团队中此通道的后端(使用 sharepoint API v1) 我打算在 Sharepoint 中发布一张带有图片/文件 url 的缩略图卡。

如果有人可以帮助我解决以下问题,那真的很有帮助:

  1. 无论如何都要修复 Sharepoint ~ Teams 之间的身份验证问题
  2. 发送图像的替代选项,如果 1. 不可行。

请帮忙:)

编辑: 添加卡片 JSON :

{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.0",
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "Sample Heading",
                    "weight": "bolder",
                    "size": "medium"
                },
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "type": "Column",
                            "width": "auto",
                            "items": [
                                {
                                    "type": "Image",
                                    "url": "https://upload.wikimedia.org/wikipedia/en/e/ea/FlowersForAlgernon.jpg",
                                    "size": "medium"
                                }
                            ]
                        },
                        {
                            "type": "Column",
                            "width": "stretch",
                            "items": [
                                {
                                    "type": "Report1",
                                    "text": "Matt Hidinger",
                                    "weight": "bolder",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "spacing": "none",
                                    "text": "Created {{DATE(2020-02-14T06:08:39Z,SHORT)}}",
                                    "isSubtle": true,
                                    "wrap": true
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

【问题讨论】:

  • Incoming webhook 现在支持自适应卡。要使用传入 Webhook 发送自适应卡片,您需要遵循 Bot 活动消息类型格式:format。您可以在其中将卡片 json 添加到内容字段。 注意:另外,由于自适应卡中没有类型“Report1”,因此您的有效负载中的这种类型“type”:“Report1”无效,您可以尝试使用正确的类型吗?
  • @Nikitha-MSFT 我已经按照您的要求使用 webhook 完成了 - 但是当我使用自适应卡时,它最终出现以下错误:Webhook 消息传递失败并出现错误:Microsoft Teams端点返回 HTTP 错误 400,ContextId MS-CV=iKFnc/DCwEmMhiAOhBMwIw.0..
  • [错误] (imgur.com/a/lM7eNgU)

标签: sharepoint microsoft-graph-api microsoft-teams microsoft-graph-teams


【解决方案1】:

Incoming webhook 现在支持自适应卡。要使用传入 Webhook 发送自适应卡片,您需要遵循 Bot 活动消息类型格式:format。您可以在其中将卡片 json 添加到内容字段。

例子:

发布网络挂钩网址

请求正文:

{
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "content": {
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.0",
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "Sample Heading",
                    "weight": "bolder",
                    "size": "medium"
                },
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "type": "Column",
                            "width": "auto",
                            "items": [
                                {
                                    "type": "Image",
                                    "url": "https://upload.wikimedia.org/wikipedia/en/e/ea/FlowersForAlgernon.jpg",
                                    "size": "medium"
                                }
                            ]
                        },
                        {
                            "type": "Column",
                            "width": "stretch",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "text": "Matt Hidinger",
                                    "weight": "bolder",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "spacing": "none",
                                    "text": "Created {{DATE(2020-02-14T06:08:39Z,SHORT)}}",
                                    "isSubtle": true,
                                    "wrap": true
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}
    }
  ]
}

结果:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2016-06-10
    相关资源
    最近更新 更多