用于传入 Webhook 的 Microsoft 卡在团队中为空

问题描述 投票:0回答:1

这可能有点通用,但我无法理解它。我正在尝试将卡片发送到团队中的传入网络钩子。我无法理解 json 文件必须采用哪种结构才能工作。

我想用 [https://adaptivecards.io (https://stackoverflow.com) 设计我的卡片,但它们总是空着。教程中显示的 https://adaptivecards.io/samples 的示例也是如此 https://www.youtube.com/watch?v=y5pbJI43Zvg.

https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-a-message-through- 上的两个示例传入 webhook-or-connector-for-microsoft-365-groups 工作。

post postman microsoft-teams webhooks
1个回答
0
投票
您似乎正在尝试将自适应卡发送到 Teams 中的传入 Webhook。通过传入 webhook 发送的自适应卡的 JSON 结构应如下所示:

{ "type":"message", "attachments":[ { "contentType":"application/vnd.microsoft.card.adaptive", "contentUrl":null, "content":{ "$schema":"http://adaptivecards.io/schemas/adaptive-card.json", "type":"AdaptiveCard", "version":"1.2", "body":[ { "type": "TextBlock", "text": "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)" } ] } } ] }
以下是关键属性的细分:
“type”:该字段必须设置为“message”。
“attachments”:该数组包含一组卡片对象。
“contentType”:此字段必须设置为“application/vnd.microsoft.card.adaptive”。
“content”:该对象是 JSON 格式的卡片。
如果您的卡到达时是空的,则自适应卡本身的 JSON 结构可能存在问题。您可以使用自适应卡设计器来设计卡并确保 JSON 格式正确。
创建自适应卡 JSON 后,您可以使用 Postman 等工具对其进行测试,将 POST 请求发送到您为传入 Webhook 设置的 URL。将 JSON 文件粘贴到请求正文中,您应该能够在 Teams 中查看自适应卡消息。

© www.soinside.com 2019 - 2024. All rights reserved.