How to get the current user permission role of a folder (or file) with MS Graph Api ?
I try : https://graph.microsoft.com/[v1.0 or beta]/drives/[driveId]/items/[itemId]/permissions
but the role array is empty for all but the owner one...
I would like to show the user a specific icon if it can read or write in a folder.
Thx
--Edit 1--
the user didn't have direct permission to the folder but he is in a security group who have the read role.
the user can read (open) any information from that folder, i just need something to know if he can read AND write (or not) in the folder.
When i try to write without the good permission i got an 403 error, i whould like to know "before" that error that the user couldn't write on that folder..
--Edit 2---
I try all that the doc say : https://learn.microsoft.com/en-us/graph/api/permission-get?view=graph-rest-1.0&tabs=http
GET /drives/{drive-id}/items/{item-id}/permissions/{perm-id} => Roles empty
GET /groups/{group-id}/drive/items/{item-id}/permissions/{perm-id} => Security groups didn't have any drive
GET /me/drive/items/{item-id}/permissions/{perm-id} => Item (folder) is not in the user drive
GET /sites/{site-id}/drive/items/{item-id}/permissions/{perm-id} => it's not a sharepoint site
GET /users/{user-id}/drive/items/{item-id}/permissions/{perm-id} => Roles empty
What i don't understand is that i can read, list, add and remove file (if i have the write role) without any problem, but i can't see the roles list..
-- Edit 3 --
If you want to reproduce the pb foolow this :
Create a user in Azure Active Directory (AAD), add to it a Microsoft Office 365 licence (in my case business) named "User1"
Create a folder in it Onedrive for Business named "Shared"
Create in AAD a Security group's (let named it "Readers")
Share the previous folder with the "Readers" group and make it read only (in my case I use the onedrive online site to do that)
Create in AAD an other User (with or without a licence) named "User2"
Add it to the "Readers" group
Now, Go to Graph Explorer and type in this url in the input textbox :
https://graph.microsoft.com/v1.0/drives/[driveId of User1]/items/[itemId of "Shared" folder]/Permissions
you should get this result :
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('...')/items('...')/permissions",
"value": [
{
"id": "...",
"roles": [],
"grantedTo": {
"user": {
"displayName": "Readers"
}
}
},
{
"id": "...",
"roles": [
"owner"
],
"grantedTo": {
"user": {
"email": "user1@mydomain.com",
"id": "...",
"displayName": "User1"
}
}
}
]
}
Has you can see, the first roles array is empty, but the owner roles array is not..