Request for detail documentation of List permissions of a drive item

Ankur Gupta 20 Reputation points
2024-07-18T06:50:42.8366667+00:00

https://video2.skills-academy.com/en-us/graph/api/driveitem-list-permissions?view=graph-rest-1.0&tabs=http#http-request

My goal is to find out if calling user have write or read permission on an item using drive-id and item-id.

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,722 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 41,036 Reputation points
    2024-07-18T09:13:54.9966667+00:00

    Hi @Ankur Gupta

    Call the GET /drives/{drive-id}/items/{item-id}/permissions endpoint directly with your calling user, then check the returned JSON response, if the roles property contains write/read, then check the grantedToV2 property to see if it contains the current calling user.

    {
      "value": [
        {
          "id": "permission-id",
          "roles": ["read"],
          "grantedToV2": {
            "user": {
              "id": "user-id",
              "displayName": "User Name"
            }
          }
        },
        {
          "id": "permission-id",
          "roles": ["write"],
          "grantedToV2": {
            "user": {
              "id": "user-id",
              "displayName": "User Name"
            }
          }
        }
      ]
    }
    

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.