Reputation: 37
Im Using MS Graph Client and having a trouble of previewing Shared Items with me.
ItemPreviewInfo preview = await graphClient.Me.Drive.Items[id].Preview().Request().PostAsync();
Gives no such file exists error as obvious cos its not in my drive. I know i need to access shared folder may be but ""raphClient.Me.Drive.SharedWithMe...." does not give any item id specifications.
Any help would be appreciated. Thank you in advance.
Upvotes: 1
Views: 605
Reputation: 241
You need to get the shared drive item by calling :
DriveItem driveItem = await graphClient.Me.Drive.SharedWithMe().Request().GetAsync().FirstOrDefault();
Once you have retrieved the shared drive item, you can preview it by calling :
ItemPreviewInfo previewInfo = await client.Drives[sharedItem.RemoteItem.ParentReference.DriveId].Items[sharedItem.RemoteItem.Id].Preview().Request().PostAsync();
Since the shared items are from a different drive, you need to get the RemoteItem-DriveId for the shared drive and the RemoteItem-Id which identifies the DriveItem in the shared drive.
This is explained here
Upvotes: 5