Search code examples
postpostmanmicrosoft-teamswebhooks

Microsoft Cards for incoming webhook arrive empty in teams


This might be a bit generic, but i cant wrap my head around it. I am trying to send a a card to my incoming webhook in teams. I cant understand which structure the json file has to be in to work.

I want to design my card with [https://adaptivecards.io (https://stackoverflow.com), but theyre always arriving empty. The same goes for the examples from https://adaptivecards.io/samples shown in their tutorial https://www.youtube.com/watch?v=y5pbJI43Zvg.

The two examples on [https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-a-message-through-incoming-webhook-or-connector-for-microsoft-365-groups] ( https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-a-message-through-incoming-webhook-or-connector-for-microsoft-365-groups) work.


Solution

  • it seems like you're trying to send an Adaptive Card to an incoming webhook in Teams. The JSON structure for an Adaptive Card sent via an incoming webhook should look like this:

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

    Here's a breakdown of the key properties: "type": This field must be set to "message". "attachments": This array contains a set of card objects. "contentType": This field must be set to "application/vnd.microsoft.card.adaptive". "content": This object is the card formatted in JSON. If your cards are arriving empty, it's possible that there's an issue with the JSON structure of the Adaptive Card itself. You can use the Adaptive Cards Designer to design your card and ensure that the JSON is correctly formatted. Once you've created your Adaptive Card JSON, you can test it using a tool like Postman to send a POST request to the URL you set up for your incoming webhook. Paste the JSON file in the body of the request, and you should be able to view the Adaptive Card message in Teams.