Search code examples
spring-bootmicrosoft-graph-apimicrosoft-teamsadaptive-cards

Send an adaptive card through Microsoft Graph API - Error when getting Submit Action


I am able to send buttons and hyperlinks using the below JSON, but whenever I am clicking on the button getting an error.enter image description here

API URL - https://graph.microsoft.com/v1.0/chats/chatId/messages JSON Request:

    "body": {
        "contentType": "html",
        "content": "<attachment id=\"74d20c7f34aa4a7fb74e2b30004247c5\"></attachment>"
    },
    "attachments": [
        {
            "id": "74d20c7f34aa4a7fb74e2b30004247c5",
            "contentType": "application/vnd.microsoft.card.thumbnail",
            "contentUrl": null,
            "content": "{\r\n  \"title\": \"This is an example of posting a card\",\r\n  \"subtitle\": \"<h3>This is the subtitle</h3>\",\r\n  \"text\": \"Here is some body text. <br>\\r\\nAnd a <a href=\\\"http://microsoft.com/\\\">hyperlink</a>. <br>\\r\\nAnd below that is some buttons:\",\r\n  \"buttons\": [\r\n    {\r\n      \"type\": \"messageBack\",\r\n      \"title\": \"Login to FakeBot\",\r\n      \"text\": \"login\",\r\n      \"displayText\": \"login\",\r\n      \"value\": \"login\"\r\n    }\r\n  ]\r\n}",
        }
    ]
}```

Solution

  • It doesn't seem to be feasible to handle button event through graph API. If you want to handle button event then you can send message/card through bot. You can send card with action buttons using HTTP request. But button actions except Action.OpenUrl will not support here.