Using PowerShell's Invoke-RestMethod, I have successfully been able to make a call to "https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/chatThreads" to post a message to my desired Team/Channel in a very neatly formatted way.
What I am now struggling with is @mentioning a user in the same message. I've followed the short tutorial on https://myteamsday.com/2019/03/05/sending-message-with-atmention-onto-a-channel-using-graphapi/
I get to the point where I added the mentions section to the body of the request, complete with id of the user and id of the mention.
Once I make the call, the message is posted but only the text as show in the content property. No link/mention to the actual user.
{
"rootMessage": {
"body": {
"contentType": "html",
"content": "Hello, World! <at id=\"0\">Jack Black</at>"
},
"mentions": [ {
"id": 0,
"mentionText": "Jack Black",
"mentioned": {
"id": "ac5e5x81-39Dd-4748-beTa-b5cd6t93ba67",
"displayName": "Jack Black",
"userIdentityType": "aadUser"
}
}
]
}
}
Here's one thing I noticed in the tutorial though, the guy references "https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/messages" , but Microsoft Graph references "https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/chatThreads"
When I replace chatThreads with message in Microsoft Graph, I get an Bad Request error message complaining about the content property cannot be null, but it is NOT null.
EDIT 1: When using https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/messages on graph explorer
{
"error": {
"code": "BadRequest",
"message": "Value cannot be null.\r\nParameter name: Content",
"innerError": {
"request-id": "f0d4fed8-7726-4338-8a68-9685a690eab5",
"date": "2019-07-02T12:46:14"
}
}
}