Forum Discussion
KeffaKlumpen
Nov 02, 2023Copper Contributor
Teams Tabs App - Finding the current team/site
I am currently developing a teams app that will be added to a few different teams.
We are using C# / .cshtml / Razor and the app consists of a few RazorComponents which performs different Graph operations on a SharePoint site.
Currently we are using a hard-coded siteId pointing to our Team-site used for testing, but now we need to find this siteId dynamically - to access the right site, depending on which team you opened the app through.
We found the MicrosoftTeams.GetTeamsContextAsync() which gives us a TeamsContext object - however the Teams field is null.
Is there a good way to do this that we just haven't found?
Or does anyone know of a not-so-good way that might work?
Or am I coming at this from the completely wrong direction?
- We found the solution to why the TeamsContext object was not being assigned any data:
In the manifest.json we had to add the "team" scope to our tab!
Here we found the ChannelContext which contains a RelativeUrl we can extract the site name from!
2 Replies
Sort By
- KeffaKlumpenCopper ContributorWe found the solution to why the TeamsContext object was not being assigned any data:
In the manifest.json we had to add the "team" scope to our tab!
Here we found the ChannelContext which contains a RelativeUrl we can extract the site name from! - Sayali-MSFT
Microsoft
KeffaKlumpen-Thanks for reporting your issue.
We will check this at our end and will get back to you.