Comments (13)
I apologize for misrepresenting the API. Even I did not know that was possible! I updated the comment above.
from onedrive-sdk-csharp.
Any news on this question?
from onedrive-sdk-csharp.
You can access another drive using client.Drives[driveId]. As long as the authenticated caller has access to the drive ID then the call should succeed.
from onedrive-sdk-csharp.
Is DriveID the user name? I've got a user with a OneDrive URL like this: https://mydomain-my.sharepoint.com/personal/usera_mydomain_onmicrosoft_com/Documents. And code like this (simplified for brevity), but it throws an exception:
` private async Task LoadUserDriveTest()
{
Item folder;
var expandValue = "thumbnails,children";
folder = await oneDriveClient.Drives[$"usera_mydomain_onmicrosoft_com"].Root.Request().Expand(expandValue).GetAsync();
//Code: invalidRequest
//Message: The provided drive id appears to be malformed, or does not represent a valid drive.
}`
from onedrive-sdk-csharp.
The DriveId is a string that uniquely identifies the drive.
The code you provided is not valid. Drives[{driveId}]
expects a DriveId, user account (email address), or AAD Object ID. Additionally, you can instead use the extension OneDriveClient.Drive
which is a shortcut to basically say "the drive of the signed-in user." If you want to access a drive other than the signed-in user, you need to first know the target user's DriveId. You can find out a user's DriveId using this simple call:
var drive = await oneDriveClient.Drive.Request().GetAsync();
var driveId = drive.Id;
[Edited for correctness]
from onedrive-sdk-csharp.
Actually, @rgregg guided me to use the SMTP address of the user as the drive ID - and it works! e.g. folder = await oneDriveClient.Drives["[email protected]"].Root.Request().Expand(expandValue).GetAsync();
from onedrive-sdk-csharp.
I've been testing this approach heavily over the weekend, and it appears flakey or some user's drives just cannot be accessed for some reason (the permissions are good). I've been seeing this error:
Code: invalidRequest Message: The provided drive id appears to be malformed, or does not represent a valid drive.
HResult: -2146233088
This has happened consistently for a certain set of users, and for two users it failed but then subsequently worked with a second or third attempt.
I will try your approach with the drive ID to see if it works - would this be the call: oneDriveClient.Drives["[email protected]"].Request().GetAsync()
from onedrive-sdk-csharp.
I tried using the Drive ID approach - it only worked for one of the users where it failed by using their email address. I will see if I can get the AAD object ID for the users where it is failing. Otherwise any guidance would be super appreciated! This is a super high-priority project and I'm going to look bad if I can't process a high percentage of users. :-( /cc @rgregg
from onedrive-sdk-csharp.
Hey Eric: Can you reach out to me directly? (rgregg -at- microsoft.com).
For failed calls, if you can send me the request ID, the date/time the request was made, and the tenant you were using, I can look up the details and sort out why you're getting that error and if we have a bug hiding or something else.
Also, just to make sure, you need to use the UPN, not a user's email address (most of the time they're the same, but not always).
from onedrive-sdk-csharp.
Me again, talking into the wind lol! Turns out it was a permissions issue - the admin account was only granted the Application Impersonation Role. This apparently adds the account to the user's Site Collection Admins, but the issues went away when he added the admin account manually.
from onedrive-sdk-csharp.
That's good to hear. Sounds like we could use a better error state though for that scenario.
from onedrive-sdk-csharp.
BTW, my apologies for totally missing your reply. I've been overcoding and need some sleep! Thanks Ryan
from onedrive-sdk-csharp.
Is there a way to grant permissions to manage a custodian user's OneDrive through the SDK? I created a SO on the question as well which has more context.
from onedrive-sdk-csharp.
Related Issues (20)
- ItemWithPath can't handle "invalid characters"
- The remote certificate is invalid according to the validation procedure error when using chunked upload
- Is there a step by step guide for how to use the latest SDK in UWP Apps? HOT 3
- Upload large file raise Unsupported segment type HOT 1
- Remove sample projects from this repo ———— 2 years ago???
- Warning NU1608 Detected package version outside of dependency constraint:
- Exception User-Unhandled HOT 4
- Authentication Problem / Failed
- Warning NU1602
- UWP XBox One Can't Interact with Sign In UI
- Not able to upload files to my OneDrive
- ItemWithPath
- Project Abandoned? HOT 3
- How to get refresh token using the GraphServiceClient uaing code flow
- Request() method throws exception
- System.MissingMethodException set_SdkVersionHeaderPrefix HOT 2
- How to use net core to call onedrive? HOT 1
- How to log in with account other than default?
- OneDrive URI Scheme HOT 1
- Invalid property identifier character.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onedrive-sdk-csharp.