Skip to content

Instantly share code, notes, and snippets.

@vman
Last active December 16, 2022 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vman/1471e262c2baafab859db1b396631880 to your computer and use it in GitHub Desktop.
Save vman/1471e262c2baafab859db1b396631880 to your computer and use it in GitHub Desktop.
const _postToTeams = async () => {
const idToken = await microsoftTeams.authentication.getAuthToken();
const teamsContext = await microsoftTeams.app.getContext();
const teamId = teamsContext.team?.groupId;
const channelId = teamsContext.channel?.id;
const message = "This message will be posted to Teams using Microsoft Graph";
await fetch(`/PostToTeams?teamId=${teamId}&channelId=${channelId}&message=${message}`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Bearer ${idToken}`
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment