Posting Mentions to Teams using Graph

I'm putting this out there because it took me some time to figure out and at the time I couldn't find any documentation on how to use the Graph API to post a mention to a Teams channel:

  1. GET Team ID: https://graph.microsoft.com/beta/me/joinedTeams
  2. GET Channel ID: https://graph.microsoft.com/beta/teams/{team-id}/channels
  3. GET User ID: https://graph.microsoft.com/v1.0/me/people/?$search="Firstname Lastname"
  4. POST https://graph.microsoft.com/beta/teams{Team ID}/channels/{Channel ID}/messages (Include the BODY of the POST as below)
Minimum JSON needed for body of the POST:
{
  "body": {
    "contentType": "html",
    "content": "<at id=\"0\">Firstname Lastname</at>Boo"
  },
  "attachments": [],
  "mentions": [
    {
      "id": 0,
      "mentionText": "Firstname Lastname",
      "mentioned": {
        "application": null,
        "device": null,
        "conversation": null,
        "user": {
          "id": "0d7ac188-610b-4194-98de-db80b6019ed1", //From Step 3 above
          "displayName": "Firstname Lastname",
          "userIdentityType": "aadUser"
        }
      }
    }
  ],
  "reactions": []
}

Comments

Popular posts from this blog

Auto-installing extensions on Firefox using Intune

Disable DNS over HTTPS in Firefox using Intune

Moving Applocker control from Group Policy to Intune