I’ve been preparing my SPS Helsinki & Teams Virtual Summit Oktoberfest sessions “Teams Graph API Fun/in practice” which are both a demo session about lots of fun (/practical) possibilities you can do with Graph API in Microsoft Teams – or in Teams related features. While I was experimenting (yes, this is a lots of experiments what is possible and how) with SharePoint app I have found that it is possible to add & configure SharePoint app as a tab to a team channel.

Team and channel ID
You will need to figure out your Team ID and of course Channel ID before going forward. I recommend you to use Graph Explorer when you are experimenting with this subject. Paste URLs and request body / headers into Graph Explorer as needed. Note: some functions require you to switch to beta API.
List of teams: https://graph.microsoft.com/v1.0/me/joinedTeams
Listing team channels: https://graph.microsoft.com/v1.0/teams/{team-id}/channels
Replace {team-id} with appropriate team id you want to use. Store team and channel id for later use. Channel ID is in format “19:GUID@thread.skype” while team id is just a GUID.
Site ID .. I mean teamsite URL
To create the Urls needed to add SharePoint pages / lists you need the site URL. One of the easiest way is just to Graph API call to group to retrieve it’s site and check out the URL from there.
https://graph.microsoft.com/beta/groups/{team-id}/sites/root
From the result we can get a webURL and id (siteID) – store these for later use.
Adding a home page of a team as tab
The good thing is that the home page is always available when you create a new team – and it is found at /SitePages/Home.aspx so you don’t have to worry about it’s name. However, you will have to worry about the URL and your team url.
The key is to create two URLs: content and website URLs. Content URL needs to have it’s special characters encoded: replace / with %2F and possible : with %3A and of course space with %20.
Content URL
This is in format of {target site url} + /_layouts/15/teamslogon.aspx?spfx=true&dest= + {encoded target site url} + %2FSitePages%2FHome.aspx
Just like this one:
https://mydomain.sharepoint.com/sites/mytestsite/_layouts/15/teamslogon.aspx?spfx=true&dest=https%3A%2F%2Fmydomain.sharepoint.com%2Fsites%2Fmytestsite%2FSitePages%2FHome.aspx
Website URL
This one is a lot easier than the content. This is just the {target site url} + /SitePages/Home.aspx. Just like in the example:
https://mydomain.sharepoint.com/sites/mytestsite/SitePages/Home.aspx
The Graph POST URI
https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id]/tabs"
JSON Body
The request body contents require SharePoint application ID (teamsAppId) and name and configuration parts.
{
"teamsAppId": "2a527703-1f6f-4559-a332-d8a7d288cd88",
"name": "SharePoint tab",
"displayName": "SharePoint page tab",
"configuration": {
"contentUrl": "{Content URL}",
"websiteUrl": "{Website URL}"
}}
And if everything went well, we just added and configured a SharePoint page tab to team channel and it didn’t even break a sweat.
You can check out more information about adding SharePoint tabs in TEams Graph API documentation. It is saying this is not supported – so you have to expect that some changes may occur to these later. https://docs.microsoft.com/en-us/graph/teams-configuring-builtin-tabs
Create a list via Graph
You can also create a list to team using Graph API. The documentation is here: https://docs.microsoft.com/en-us/graph/api/list-create?view=graph-rest-1.0&tabs=http
When creating a list you can define all columns etc. Note that you need a SiteID for the creation. And as it happens, we already have the site ID stored.
Check out the Docs for details how to create a list. The POST request is
https://graph.microsoft.com/beta/sites/{site-id}/lists
in return you get list’s ID and webURL. We need the weburl, so store it.
Adding a list as tab
We need similar tricks on list urls as we did when adding a page.
List Content Url
This is in format of {target site url} + /_layouts/15/teamslogon.aspx?spfx=true&dest= + {encoded target site url} + %2FLists%2F + {listname, if necessary encoded!} + %2FAllItems.aspx%3Fp%3D11
Example
https://mydomain.sharepoint.com/sites/mytestsite/_layouts/15/teamslogon.aspx?spfx=true&dest=https%3A%2F%2Fmydomain.sharepoint.com%2Fsites%2Fmytestsite%2FLists%2FMy%20Test%20List%2FAllItems.aspx%3Fp%3D11
List Web Url
Just like with SharePoint page, this one is simpler: {list web url from creation} + AllItems.aspx?p=11. Just like in the example:
https://mydomain.sharepoint.com/sites/mytestsite/Lists/My%20Test%20List/AllItems.aspx?p=11
POST URL and JSON Body
These are the same as in the page adding example. Just use correct name and URLS in configuration section.
Was this cool and useful?
I think this was extremely useful to experiment with. This opens new paths to include when provisioning a teams in organizations, automating adding of home page and creation of required lists and adding them to a team.
If you like this then you should attend my Teams Virtual Summit Oktoberfest session on 16.10. or check it’s recording later (if one is made). And if you are in Helsinki 28.9. – come and see this live on SPS Helsinki stage!
In my case I need to create a list not at the root of the site but in a sub-folder, for e.g. by default when you create a list just like how you have done, you will notice in the webURL of the response the path being “https://…/sites/dev/Lists/”
Instead I want something like
“https://…/sites/root/Project/MyGroup/Lists/MyList”
Upon asking in StackOverflow, I was suggested to use parentReference in the body (payload), and I did something like this
“parentReference”: {
“driveType”: “Documents”,
“driveId”: “{my-drive-id}”,
“path”: “/drives/{my-drive-id}/root:/Project/”
}
Still the end result is same it creates at the root as “https://…/sites/root/Lists/MyList”
Any help is appreciated.
LikeLike
To my knowledge you can’t create folders where you would store different lists. Instead you would be creating a subsite to your site collection and create those “foldered” lists there. It is the same with document libraries – you can not create a doclib under another doclib either.
But I would like to question your need to create lists in subsites (or folders) in the first place. Perhaps it would be better to think how you are showing these lists to users, instead of planning a folder structure where to store them. Instead of subsites those lists would be stored in different site collections (sites) and you could manage permissions and so on with sites.
LikeLike