how to send an adaptive card through microsoft Graph API

Karnati Soumya 1 Reputation point
2020-11-11T07:12:51.327+00:00

How to Send a message and adaptive card to group or an individual chat through Microsoft graph API.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,692 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,879 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deva-MSFT 2,256 Reputation points Microsoft Employee
    2020-11-13T13:56:39.083+00:00

    You can send an adaptive card through Microsoft Graph API in a specified Teams channel. Following is an example of the request - using this you can create a new chatMessage in the specified channel.

    POST https://graph.microsoft.com/v1.0/teams/{id}/channels/{id}/messages  
    Content-type: application/json  
      
    {  
        "subject": null,  
        "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}",  
                "name": null,  
                "thumbnailUrl": null  
            }  
        ]  
    }