I would like to get the files within a team, just like they have them in the files tab.
I would like to replicate this on my own tab, just can't find anything where to start from.
I would also like to download the contents of the file(get the content in some way, base64, uint array...
CodePudding user response:
You need to know team_id
and channel_id
To list all teams in an organization you need to get a list of groups that have a resourceProvisioningOptions
property that contains "Team".
Endpoint to list teams
GET https://graph.microsoft.com/v1.0/groups?$select=id,resourceProvisioningOptions
Endpoint to list team's channels (use id from previous query)
GET https://graph.microsoft.com/v1.0/teams/{team_id}/channels
Endpoint to get files and folders
GET https://graph.microsoft.com/v1.0/teams/{team_id}/channels/{channel_id}/filesFolder
The query above returns metadata about driveItem.
Use parentReference.driveId
and id
in the next API call to get folders and files
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{id}/children
It returns a collection of driveItems
with unique id
.
- If
driveItem
represents a file thenfile
property is not null.
For each item that represents the file you can call
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}
to get more details about the file.
- If
driveItem
represents a folder thenfolder
property is not null.
For each item that represents the folder you can call
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}/children
to get more details about the folder or to get items inside the folder.
If you want to download the content then call
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}/content
Resources: