microsoftgraph / msgraph-sdk-dotnet

Microsoft Graph Client Library for .NET!
https://graph.microsoft.com
Other
699 stars 248 forks source link

CustomDriveItemItemRequestBuilder doesn't delete Permissions #2258

Open BenjaminMichaelis opened 10 months ago

BenjaminMichaelis commented 10 months ago

The CustomDriveItemItemRequestBuilder doesn't do what DriveItemItemRequestBuilder can do.

Ex:

        var site = $"{options.Host}:/sites/{options.SiteName}";
        _site ??= await graphServiceClient.Sites[site].GetAsync();
        var drive = await graphServiceClient.Sites[_site?.Id].Drive.GetAsync();
        var item = await graphServiceClient.Drives[drive?.Id].Root.ItemWithPath(root + path).GetAsync();

        DriveItemItemRequestBuilder folder = await graphServiceClient.Drives[drive?.Id].Items[item?.Id];

        await folder.Permissions[permission.Id].DeleteAsync();

With permission.Id being gotten from Graph API already (with value of like YzowdC5jfHRlbmFubHwtPYFxNWQwNi04NjDzLTRkNzctOWY4OS2mM1JmDMNMIWEzM2P works fine, but

        var site = $"{options.Host}:/sites/{options.SiteName}";
        _site ??= await graphServiceClient.Sites[site].GetAsync();
        var drive = await graphServiceClient.Sites[_site?.Id].Drive.GetAsync();

        CustomDriveItemItemRequestBuilder folder = graphServiceClient.Drives[drive?.Id].Root.ItemWithPath(root + path);

        await folder.Permissions[permission.Id].DeleteAsync();

doesn't work (ODataError : Item not found).

I expect DriveItemItemRequestBuilder to work the same as CustomDriveItemItemRequestBuilder as the only difference in being able to get one of these types is whether when getting a drive item, ItemWithPath() or Items[item.Id] is used and Permissions.DeleteAsync() exists on both.

andrueastman commented 10 months ago

Thanks for raising this @BenjaminMichaelis

Any chance you can confirm if the url built is as expected by confirming the url string is as expected?

var URL = folder.ToDeleteRequestInformation().URI.OriginalString;
BenjaminMichaelis commented 10 months ago

Thanks for raising this @BenjaminMichaelis

Any chance you can confirm if the url built is as expected by confirming the url string is as expected?

var URL = folder.ToDeleteRequestInformation().URI.OriginalString;

From what I can tell? I'm not an expert at reading the url's so I'm not positive, but since the only different is additional call to pass in the id or not and that is what the sdk allows for I'm confused on the needing to check the URL's. I would expect both should work, and the SDK does the heavy lifting for me.

andrueastman commented 10 months ago

I'm more curious about whether adding root parameter is necessary in ItemWithPath(root + path) this is because, the Drives[drive?.Id].Root already contains root and adding it twice will result in an invalid path relative to the folder you're trying to address.

BenjaminMichaelis commented 10 months ago

I'm more curious about whether adding root parameter is necessary in ItemWithPath(root + path) this is because, the Drives[drive?.Id].Root already contains root and adding it twice will result in an invalid path relative to the folder you're trying to address.

The root isn't actually "root", it's the default folder name under the true "root" of which all the files are stored under relatively.