Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Client bug]: Graph client V5: SharePoint list driveitem permissions GrantedToV2 returns null #2149

Closed
xinzhaozhang1985 opened this issue Oct 3, 2023 · 2 comments

Comments

@xinzhaozhang1985
Copy link

xinzhaozhang1985 commented Oct 3, 2023

Describe the bug
We are upgrading from v4 to v5, when we request permissions for a site list driveitem, the GrantedToV2 object in permission is null.
It was working in the V4, but it is broken in V5. Also checked with graph explore, it is working as epected.

To Reproduce
Steps to reproduce the behavior:

  1. Create a document in SharePoint

  2. Install Nuget package v4 and construct request as below:
    var request = graphClient
    .Sites[]
    .Lists[]
    .Items[]
    .DriveItem
    .Permissions
    .Request();
    var permissions = await request.GetAsync();
    Inspect the GrantedToV2 object in permissions and they are not empty

  3. Upgrade the Nuget package to V5 and construct request as below:
    var item = await graphClient
    .Sites[]
    .Lists[]
    .Items[]
    .DriveItem
    .GetAsync(requestConfiguration =>
    {
    requestConfiguration.QueryParameters.Expand = new string[] { "Permissions" };
    });
    Inspect the GrantedToV2 object in permissions and they are empty

  4. Validates the permissions returns correctly in Graph Explore

Expected behavior
GrantedToV2 and GrantedToIdentitiesV2 should be populated if they are not null.

Screenshots
V5

V4

The first screenshot is using V5 and the second screenshot is using V4. You can see from the screenshot, the permission Id are the same to indicate I am requesting permissions for the same file
Client version
Nuget package version 5.28

Desktop (please complete the following information):

  • OS: Windows
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@MartinM85
Copy link
Contributor

The issue is that there are two different queries

Query created from your code by SDK v4

GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/driveItem/permissions

Query created by SDK v5

GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/driveItem?$expand=permissions

The same behavior can be reproduced in Graph Explorer. The second query doesn't return GrantedToV2.

Another issue is that in SDK v5 you can't create this

var item = await graphClient
.Sites[]
.Lists[]
.Items[]
.DriveItem
.Permissions
.GetAsync();

Permissions navigation property is not exposed in this case

You need to make two calls, one call to get a driveItem and then the second call to get permissions through the /drives endpoint

var driveItem = await graphClient
.Sites[""]
.Lists[""]
.Items[""]
.DriveItem
.GetAsync();

var permissions = await graphClient.Drives[driveItem.ParentReference.DriveId].Items[driveItem.Id].Permissions.GetAsync();

@xinzhaozhang1985
Copy link
Author

xinzhaozhang1985 commented Oct 4, 2023

Thanks. I can get the grantedToV2 permissions using two calls now.

This thread can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants