Microsoft Teams Webhook Generating 400 for Adaptiv

2020-06-03 08:43发布

I have a functioning webhook to a Teams channel to which I can successfully post messages. I am now trying to post an adaptive card to the webhook. Using Postman and performing a Post to https://outlook.office.com/webhook/xyz, with Content-Type set to application/json in the header and the following adaptive card set in the body.

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.0",
  "speak": "Nothing to say.",
  "body": [
    {
      "type": "TextBlock",
      "text": "Hello Teams' user"
    }
  ]
}

With this I receive a HTTP 400 Bad Request and Summary or Text is required message. Does anyone know if Teams webhooks support Adaptive Cards yet or if this is an unsupported task currently?

2条回答
一夜七次
2楼-- · 2020-06-03 08:57

For simple use cases POST this to the webhook url:

{
  "title": "Action News",
  "text": "not **much** happend (markdown)"
}

For advanced use cases try using MessageCard: https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using

Example:

{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "Larry Bryant created a new task",
"sections": [{
    "activityTitle": "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png)Larry Bryant created a new task",
    "activitySubtitle": "On Project Tango",
    "activityImage": "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
    "facts": [{
        "name": "Assigned to",
        "value": "Unassigned"
    }, {
        "name": "Due date",
        "value": "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
    }, {
        "name": "Status",
        "value": "Not started"
    }],
    "markdown": true
}],
"potentialAction": [{
    "@type": "ActionCard",
    "name": "Add a comment",
    "inputs": [{
        "@type": "TextInput",
        "id": "comment",
        "isMultiline": false,
        "title": "Add a comment here for this task"
    }],
    "actions": [{
        "@type": "HttpPOST",
        "name": "Add comment",
        "target": "http://..."
    }]
}, {
    "@type": "ActionCard",
    "name": "Set due date",
    "inputs": [{
        "@type": "DateInput",
        "id": "dueDate",
        "title": "Enter a due date for this task"
    }],
    "actions": [{
        "@type": "HttpPOST",
        "name": "Save",
        "target": "http://..."
    }]
}, {
    "@type": "ActionCard",
    "name": "Change status",
    "inputs": [{
        "@type": "MultichoiceInput",
        "id": "list",
        "title": "Select a status",
        "isMultiSelect": "false",
        "choices": [{
            "display": "In Progress",
            "value": "1"
        }, {
            "display": "Active",
            "value": "2"
        }, {
            "display": "Closed",
            "value": "3"
        }]
    }],
    "actions": [{
        "@type": "HttpPOST",
        "name": "Save",
        "target": "http://..."
    }]
}]
}
查看更多
对你真心纯属浪费
3楼-- · 2020-06-03 09:02

Webhooks do not yet support Adaptive Cards! We plan to add support for Adaptive Cards shortly after we release them for bots.

查看更多
登录 后发表回答