In MS Teams, I have a class - essentially a team set up using the 'class' template that provides three user groups: Owners (teachers), Members (students) and Visitors (not used).
This comes with a 'Class Materials' drive that has, by default, read/write for teachers and read-only for students.
I am using the MS Graph API to create folders with permissions for individual students on the 'Class Materials' drive. I first create a general folder 'assignments', then a subfolder for each student that only this student can see. To do this, I remove the 'Members' (all students) permissions on the subfolders, then give each student individual permission to see their own folder.
The problem is, removing the 'Members' permission on a subfolder also removes that permission from the 'assignments' folder. I have tried adding it back manually on the web GUI, and this works - every student can see their folder and nothing else (adding the permission back on the parent folder does not cause subfolders to inherit). But I need a way to set that permission via the API.
To do this, it seems like I need a way to get the ID of the "all students" (Members) group for the class.
An API call to
https://graph.microsoft.com/v1.0/drives/$driveId/items/$folderId/permissions
on a newly created folder (that has 'owner' permissions for owners, and 'read' permissions for members by default) returns this snippet for the members (I have starred out the specific IDs):
{
"@deprecated.GrantedTo": "GrantedTo has been deprecated. Refer to GrantedToV2",
"id": "*****",
"roles": [
"read"
],
"shareId": "*****",
"grantedToV2": {
"siteGroup": {
"@odata.type": "#microsoft.graph.sharePointIdentity",
"displayName": "grp-TestingClass Members",
"id": "5",
"loginName": "grp-TestingClass Members"
}
},
"grantedTo": {
"user": {
"displayName": "grp-TestingClass Members"
}
},
"inheritedFrom": {}
}
}
This doesn't seem to contain a GUID for the "TestingClass Members" group? By contrast, the entry for the owners contains a field grantedV2.group.id with a full GUID.
So - how can I look up the GUID for my "Members" group via the API? Note, it must be an API call, so that we can create classes and assignments fully automatically as part of a larger script.