Forum Discussion

troyhart's avatar
troyhart
Copper Contributor
Jan 16, 2024

Posting adaptivecard to teams incoming webhooks

I have encountered a strange issue that I cannot get past. It has to do with MS Teams incoming webhooks and AdaptiveCards. The issue is that webhooks on some (not all) channels have stopped working. They worked initially for a good month or so before some stopped working. I have been able to verify that when a webhook stops working for a given channel that I cannot create a new webhook for the channel that will work, at least not for the payload that is required. The AdaptiveCard payloads always include "actions". However, while troubleshooting I noticed that if I remove the actions section from the AdaptiveCard that the webhook will accept the POST.

 

Has anyone encountered anything like this?

 

Below are a couple sample payloads that I can use to demonstrate this issue in our teams server. The first one includes the `actions` section and will always fail on a channel that has become corrupted. The second one is the same payload as the first, but it omits the problematic `actions` section. NOTE: both payloads can be successfully posted to an incoming webhook on a channel that is not corrupted. NOTE, I am suggesting the channel is corrupted because that is the best way to describe the symptoms I am experiencing.

 

1. payload with `actions`:

 

{
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "contentUrl": null,
      "content": {
        "type": "AdaptiveCard",
        "schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.6",
        "body": [
          {
            "text": "🚀 testing",
            "wrap": true,
            "size": "Large",
            "weight": "Bolder",
            "color": "Good",
            "type": "TextBlock"
          },
          {
            "facts": [
              {
                "title": "DeploymentId: ",
                "value": "dep-id-123"
              }
            ],
            "type": "FactSet"
          },
          {
            "actions": [
              {
                "title": "GitHub Org",
                "url": "https://github.com/myriadgenetics",
                "type": "Action.OpenUrl"
              }
            ],
            "separator": true,
            "spacing": "Default",
            "height": "Automatic",
            "holizontalAlignment": "Left",
            "type": "ActionSet"
          }
        ]
      }
    }
  ]
}

 

 

2. payload w/o `actions`:

  • troyhart's avatar
    troyhart
    Copper Contributor

    troyhart 

     

    My original message was truncated. Here's the payload that will successfully POST because it is missing the `actions` section:

    {
      "type": "message",
      "attachments": [
        {
          "contentType": "application/vnd.microsoft.card.adaptive",
          "contentUrl": null,
          "content": {
            "type": "AdaptiveCard",
            "schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "version": "1.6",
            "body": [
              {
                "text": "🚀 testing",
                "wrap": true,
                "size": "Large",
                "weight": "Bolder",
                "color": "Good",
                "type": "TextBlock"
              },
              {
                "facts": [
                  {
                    "title": "DeploymentId: ",
                    "value": "dep-id-123"
                  }
                ],
                "type": "FactSet"
              }
            ]
          }
        }
      ]
    }
    • Meghana-MSFT's avatar
      Meghana-MSFT
      Icon for Microsoft rankMicrosoft
      Thank you for reporting this, we will check this and get back to you.
      • Meghana-MSFT's avatar
        Meghana-MSFT
        Icon for Microsoft rankMicrosoft

        troyhart - We checked the payload with `actions`. We also got Webhook message delivery failed with error: Microsoft Teams endpoint returned HTTP error 400 with ContextId 01=2 error. We see that 

        height property accepts "auto" or "stretch". After changing the height value from automatic to auto/stretch, JSON is working fine.

        Please change this value to "auto" or "stretch" and try to send the payload again.  Please confirm if this helps?

Resources