问题
I can't figure out the proper syntax to open another user's OneDrive folder. What am I doing wrong? The parameter is supposed to be "ID", but is that a user ID/name, a drive ID - what? Below is some pseudo-code, based on the OneDrive API Browser sample.
I get this error: "The provided drive id appears to be malformed, or does not represent a valid drive."
private async Task LoadUserDriveTest()
{
Item folder;
var expandValue = "thumbnails,children";
folder =
await oneDriveClient
.Drives[$"user_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.
}
回答1:
For a drive identifier, you can use any of these:
- User's UPN address (usera@mydomain.onmicrosoft.com)
- User's object ID in AAD (guid)
- DriveID previously obtained by other means (say, by having a shared item return a parentReference property with a driveID).
You'd think I would have documented that here, but apparently I need to do some more writing.
来源:https://stackoverflow.com/questions/40232058/accessing-another-users-drive-using-the-onedrive-sdk