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

OneDrive API calls doesnot have any provision for Delegated and Apponly authentication types. #2211

Closed
Neelabhra08 opened this issue Nov 11, 2023 · 4 comments

Comments

@Neelabhra08
Copy link

https://graph.microsoft.com/v1.0/drives/Me/items/01J4YTV6BO73AXJWFW3JEZU3DYNCXMCWA7/permanentDelete - This call requires a DriveID which is "Me" here. I bypassed this call by modifying the the request URI - https://graph.microsoft.com/v1.0/me/drive/items/01J4YTV6BO73AXJWFW3JEZU3DYNCXMCWA7/permanentDelete and this works fine.

But cannot find any way around to work with the Apponly access where userID is needed as https://graph.microsoft.com/v1.0/{userID}/drive/items/01J4YTV6BO73AXJWFW3JEZU3DYNCXMCWA7/permanentDelete isn't working.

The main goal is to not do a extra call for fetching the driveId to execute OneDrive calls. Can anyone help with these please.

@andrueastman
Copy link
Member

Thanks for raising this @Neelabhra08

Taking a look at your url, the users segment looks to be missing. Any chance it works out if you use this by adding the users segment before the user-id?

https://graph.microsoft.com/v1.0/users/{userId}/drive/items/{item-d}/permanentDelete

@Neelabhra08
Copy link
Author

Neelabhra08 commented Nov 19, 2023

@andrueastman Hey, thanks for responding. The call works fine in the graph explorer but doesnot have support for C# or Dotnet SDK. Can you suggest what will be the call if we are implementing it in C#.

@andrueastman
Copy link
Member

Thanks for the feedback, the path missing in the SDK is due to what is explained in the guidance at the link below.
https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/docs/upgrade-to-v5.md#drive-item-paths

To resolve this you can either get the drive id and use the available requestbuilders as below.

         //get the user drive id
         var userDrive = await graphClient.Users["user-id"].Drive.GetAsync();
         await graphClient.Drives[userDrive.Id].Items["item-id"].PermanentDelete.PostAsync();// delete the item

or override the url as you desire using the WithUrl method as below.

         //use the url to override
         await graphClient.Drives[""].Items[""].PermanentDelete.WithUrl("https://graph.microsoft.com/v1.0/users/{userId}/drive/items/{item-d}/permanentDelete").PostAsync();// delete the item

@Neelabhra08
Copy link
Author

@andrueastman the method worked fine. Thanks for quick response.

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

No branches or pull requests

2 participants