Forum Discussion
Issue Retrieving File Content from SharePoint Using Microsoft Graph API - Seeking Resolution
Hello Microsoft Tech Community,
I am facing a problem while attempting to retrieve the content of a file saved on SharePoint using the Microsoft Graph API. I have tried multiple approaches, but unfortunately, I am encountering errors.
Approach 1:
var fileContentStream = await graph.Shares[drive.WebUrl].DriveItem.Content
.Request()
.GetAsync();
Error: "Resource not found."
Approach 2:
var fileContentStream = await graph.Drives[drive.ParentReference.Id]
.Root
.Request()
.GetAsync();
Error: "Malformed drive.ParentReference.Id."
Approach 3:
var fileContentStream = await graph.Groups[groupId]
.Drives[drive.ParentReference.Id]
.Items[drive.Id]
.Content
.Request()
.GetAsync();
Error: "Malformed drive.Id."
It's worth noting that the file I am attempting to access is confirmed to exist on SharePoint and is accessible through the SharePoint interface. I have verified the correctness of the drive.Id and drive.ParentReference.Id with the file saved on SharePoint, and they match.
I would appreciate any insights, guidance, or solutions the community can provide to help resolve this issue.
Thank you in advance for your assistance.