Add a Channel mention to an adaptive card

Copper Contributor

All,

 

Using the beta version of the API, with the help of the documentation, I'm able to use graph to send a team mention to a channel and I'm also able to send an adaptive card to a channel but I can't send a team mention to a channel in an adaptive card, any help?

 

{ 
    "importance": "high",
    "subject": "This is a mention",
    "body": 
        { 
 "contentType": "html", 
 "content": "Text goes here. <br/> <at id ='0'></at> <br/><br/>"
        } ,
 "mentions": [
   {
     "id": 0,
     "mentionText": "test",
     "mentioned": {
                       "conversation": {
                         "id": "",
                        "displayName": "test",
                           "conversationIdentityType": "team"
                       }
     }
   }
 ]
}


{
    "subject": null,
    "body": {
        "contentType": "html",
        "content":  "<attachment id=" + randomKey + "></attachment>"
    },
    "attachments": [{
        "id": randomKey,
        "contentType": "application/vnd.microsoft.card.thumbnail",
        "contentUrl": null,
        "content": { 
                    "title": "Test title",
                    "text": "textgoes here",
                     "buttons": [{
                     "type": "openUrl",
                     "title": "Button",
                     "value": "https://microsoft.com"
                     },
                     {
                        "type": "openUrl",
                        "title": "Button2",
                        "value": "https://google.com"
                        }    
                     ]},
        "name": null,
        "thumbnailUrl": null
    }]
}

 

6 Replies
@beepboop - Could you please share the error log details for your issue.

I've attempted to build a JSON script to perform this action:

{
    "importance":"high",
    "subject":"This is a mention",
    "body":{
        "contentType":"html",
        "content":"Text goes here. <br/> <at id ='0'></at> <br/><br/>"
    },
    "mentions":[
        {
            "id":0,
            "mentionText":"",
            "mentioned":{
                "conversation":{
                    "id":"0",
                    "displayName":"teamName",
                    "conversationIdentityType":"team"
                }
            }
        }
    ],
    "attachments":[
        {
            "id":"randomKey",
            "contentType":"application/vnd.microsoft.card.thumbnail",
            "contentUrl":null,
            "content":{
                "title":"Test title",
                "text":"textgoes here",
                "buttons":[
                    {
                        "type":"openUrl",
                        "title":"Button",
                        "value":"https://microsoft.com"
                    },
                    {
                        "type":"openUrl",
                        "title":"Button2",
                        "value":"https://google.com"
                    }
                ]
            },
            "name":null,
            "thumbnailUrl":null
        }
    ]
}

The error I receive is:

Method failed: (/beta/teams/) with code: 400

{"error":{"code":"BadRequest","message":"Invalid request body was sent.",

 

 

@beepboop - Look like your JSON is invalid, could you please verify your JSON body & try it again.
@beepboop - Look like you haven't added attachment reference in body section like below:
"body": {
"contentType": "html",
"content": "<attachment id=\"74d20c7f34aa4a7fb74e2b30004247c5\"></attachment>"
},

Because of it it's throwing error 400.
@beepboop - Can you please try to add @mention on adaptive card attachment and then send the card.

@beepboop - Could you please let us know whether it is resolved or still looking for it's solution?

Thanks,

Chetan Sharma

------------------------------------------------------

If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.