这可能有点通用,但我无法理解它。我正在尝试将卡片发送到团队中的传入网络钩子。我无法理解 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 工作。
{
"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 中查看自适应卡消息。