首页 > 解决方案 > MS 团队传入 Webhook 生成 400 以发送文本格式

问题描述

我试图使用 curl 将一些来自 Azure DevOps Pipeline 通知的通知发布到 MS 团队频道。我使用了 MS 文档中的 Text Features Adaptive 卡,它无法发布消息。其他自适应卡能够使用以下 curl 命令发布通知。

curl -XPOST -H "Content-type: application/json" -d '{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": “1.0”,
"body": [
    {
        "type": "TextBlock",
        "text": "This is some **bold** text"
    },
    {
        "type": "TextBlock",
        "text": "This is some _italic_ text"
    },
    {
        "type": "TextBlock",
        "text": "- Bullet \r- List \r",
        "wrap": true
    },
    {
        "type": "TextBlock",
        "text": "1. Numbered\r2. List\r",
        "wrap": true
    },
    {
        "type": "TextBlock",
        "text": "Check out"
    }
]
}'https://outlook.office.com/webhook/fdb-XXXX-XXXX-XXXX/e966e859-4ec9-497a-b1b8-5e6fadb19404 
(sample Income web-Hook)

我收到了无效的 webhook URL 或 HTTP 400 错误请求,并且摘要或文本是必需的消息。MS Teams 自适应卡片能否通过传入的 webhook 通知支持文本功能?

标签: webhooksmicrosoft-teams

解决方案


是的,它支持“文本”功能。请参阅此处了解更多详情。

这是示例 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)",
            }
         ]
      }
   }
 ]
}

推荐阅读