Get "List Permissions" for driveItem's children in a single request.

SunCrm 20 Reputation points
2023-10-20T19:26:50.77+00:00

To obtain the permissions of each child of a driveItem, I will need to make a separate request for each child at the path '/drives/{drive-id}/items/{sub-driveItem-id}/permissions.' If I have a driveItem with many children (2000), this becomes problematic. I am curious if there is another solution that would allow me to retrieve all the permissions of the children with fewer requests.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,292 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,045 questions
{count} votes

Accepted answer
  1. CarlZhao-MSFT 42,531 Reputation points
    2023-10-23T08:08:58.4066667+00:00

    Hi @SunCrm

    The documentation notes this:

    The permissions relationship of DriveItem cannot be expanded as part of a call to get DriveItem or a collection of DriveItems. You must access the permissions property directly.

    It seems that we are not currently able to extend the permissions of the driveitem collection. Calling the /permissions API for each driveitem is the only way.

    You can try using Graph SDK to get a collection of driveitems and iterate over the collection to get each sub-driveitem id and pass this id.

    var subItems = await graphClient.Drives["{drive id}"].Items["{item id}"].Children.GetAsync();
    
    foreach (var subItem in subItems.Value) {
    
        var permissions = await graphClient.Drives["{drive id}"].Items[subItem.Id.ToString()].Permissions.GetAsync();
    
        Console.WriteLine(permissions);
    }
    

    User's image

    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2023-10-20T19:26:50.7733333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To retrieve all the permissions of the children of a driveItem with fewer requests, you can use the expand query parameter to include the permissions of the children in the response. You can use the following API path to retrieve the children of a driveItem with their permissions in a single request: /drives/{drive-id}/items/{item-id}/children?$expand=permissions. This will return a list of driveItems with their permissions included in the response.


    References:


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.