'How to invite user to a team using Graph API?

I can invite a user with Grap API /invitations endpoint:

POST https://graph.microsoft.com/v1.0/invitations
Content-type: application/json

{
  "invitedUserEmailAddress": "[email protected]",
  "inviteRedirectUrl": "https://myapp.contoso.com",
  "sendInvitationMessage": true
}

In this cas a mail is sent to the invited user. It is OK.

I can add this user to a team with /teams/<team-id>/members endpoint. But it does not send invitation email to the user.

POST https://graph.microsoft.com/v1.0/teams/<team-id>/members
Content-type: application/json

{
    "@odata.type": "#microsoft.graph.aadUserConversationMember",
    "roles": ["guest"],
    "[email protected]": "https://graph.microsoft.com/v1.0/users('<user-id>')"
}

The /invitations endpoint does not have any options to set team-id the user is invited to.

When I add a user to a team using MS Teams application then the user automatically receives an invitation mail containing the URL of the team the user is invited to. I can send an invitation mail using /invitations endpoint anytime. But this mail containys only the domain the user is created. It does not contain the URL of the team the user is has been added.

How can I send an invitation mail containing the URL of the team the user is added to?



Solution 1:[1]

We got an update from the engineering team saying, adding a member to the team won't send invitation. Only invite API sends invitation email. Also, currently It is not possible to send message with HTML formatting.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Meghana-MSFT