Microsoft Graph: Uploading files to shared with me

2019-08-18 07:22发布

问题:

I was able to successfully upload to Shared Documents folder using this approach. But I am looking for a way to upload files to Shared WithMe folder on OneDrive.

Is it possible to upload to "/Shared WithMe" folder on OneDrive? If so, which is the right syntax for the PUT (small file) or POST (upload session)? I spent a lot of time to figure this out but no luck.

Any help would be greatly appreciated.

回答1:

I had success with this approach:

PUT /drives/{driveid}/items/{itemid}/content

I was able to retrieve the driveid and the itemid from the DriveItem entity. For a given DriveItem, the driveid is at DriveItem.RemoteItem.ParentReference.DriveId (ItemReference docs) and the itemid is at DriveItem.RemoteItem.Id (RemoteItem docs).

The Files.ReadWrite.All permission seems to be required.

This approach worked for me in the UWP C# Graph SDK.