Azure / logicapps

Azure Logic Apps labs, samples, and tools
MIT License
367 stars 302 forks source link

Posting adaptive card on Teams with "Card Type Id" fails #942

Closed Strandfelt closed 8 months ago

Strandfelt commented 10 months ago

Describe the Bug

I have a logic app that posts to a teams channel. However, when I specify the "Card Type Id" on the action, which is needed to be able to record responses in power automate, I get an error:

{
  "error": {
    "code": 400,
    "message": "Environment id is null or empty",
    "source": "logic-apis-westeurope.azure-apim.net",
    "path": "choose[13]\\when[1]\\choose\\when[1]",
    "policyId": "",
    "clientRequestId": "e31a478c-c814-4b98-874d-78774fab0cba"
  }
}

This seems to also be reported here: https://stackoverflow.com/questions/74731774/environment-id-is-null-or-empty-error-when-posting-an-adaptive-card-to-teams-a

Plan Type

Consumption

Steps to Reproduce the Bug or Issue

  1. Create logic app with an "Post card in chat or channel" action
  2. Specify the "Card Type Id" on the action
  3. Run the action and see the error
  4. Remove "Card Type Id" and see that it now works

Workflow JSON

{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "type": "Request",
        "kind": "Http"
      }
    },
    "actions": {
      "Compose": {
        "type": "Compose",
        "inputs": {
          "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
          "body": [
            {
              "columns": [
                {
                  "items": [
                    {
                      "items": [
                        {
                          "color": "Warning",
                          "size": "Large",
                          "text": "Incident title",
                          "type": "TextBlock",
                          "weight": "Bolder",
                          "wrap": true
                        },
                        {
                          "isSubtle": true,
                          "spacing": "None",
                          "text": "Created 2023-12-22T09:34:30.2767364Z",
                          "type": "TextBlock",
                          "wrap": true
                        },
                        {
                          "text": "Incident message",
                          "type": "TextBlock",
                          "wrap": true
                        }
                      ],
                      "type": "Container"
                    }
                  ],
                  "type": "Column",
                  "width": "stretch"
                }
              ],
              "type": "ColumnSet"
            },
            {
              "items": [
                {
                  "color": "Accent",
                  "size": "Default",
                  "text": "Source",
                  "type": "TextBlock",
                  "weight": "Bolder",
                  "wrap": true
                }
              ],
              "type": "Container"
            }
          ],
          "type": "AdaptiveCard",
          "version": "1.3"
        },
        "runAfter": {}
      },
      "Post_card_in_a_chat_or_channel": {
        "type": "ApiConnection",
        "inputs": {
          "host": {
            "connection": {
              "name": "@parameters('$connections')['teams']['connectionId']"
            }
          },
          "method": "post",
          "body": {
            "recipient": {
              "groupId": "REDACTED",
              "channelId": "REDACTED"
            },
            "messageBody": "@{outputs('Compose')}",
            "cardTypeId": "IncidentCard"
          },
          "path": "/v1.0/teams/conversation/adaptivecard/poster/Flow bot/location/@{encodeURIComponent('Channel')}"
        },
        "runAfter": {
          "Compose": [
            "Succeeded"
          ]
        },
        "operationOptions": "DisableAsyncPattern"
      }
    },
    "outputs": {},
    "parameters": {
      "$connections": {
        "type": "Object",
        "defaultValue": {}
      }
    }
  },
  "parameters": {
    "$connections": {
      "value": {
        "teams": {
          "id": "/subscriptions/REDACTED/providers/Microsoft.Web/locations/westeurope/managedApis/teams",
          "connectionId": "/subscriptions/REDACTED/resourceGroups/REDACTED/providers/Microsoft.Web/connections/teams",
          "connectionName": "teams"
        }
      }
    }
  }
}

Screenshots or Videos

image

Additional context

No response

AB#26859176

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 45 days with no activity.

github-actions[bot] commented 8 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.

Strandfelt commented 8 months ago

Please reopen