通过Webhook发布到团队时,共享点中托管的图像不显示

时间:2020-06-18 12:37:29

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

我正在尝试将某些报告从松弛状态迁移到Microsoft Teams。 当前,我们正在将图像和csv文件发布到Azure函数中以松弛。

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

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

浏览器中的团队显示图像,但桌面应用程序不显示。同样,他们也不会在我的移动应用中显示给团队。

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

如果有人可以帮助我进行以下工作,那将真的有帮助:

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

请帮助:)

编辑: 添加卡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
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

1 个答案:

答案 0 :(得分:0)

传入Webhook现在支持自适应卡。要使用传入的Webhooks发送自适应卡,您需要遵循Bot Activity Message Type格式:format。您可以在其中将卡片json添加到内容字段。

示例:

发布Web挂钩URL

请求正文:

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

结果: enter image description here