Ram's
Ram's

Reputation: 121

Cannot access the files from sharepoint online through Graph API

I was trying to access the files from Sharepoint Online using the Graph API. I have few files in the Sharepoint site in the drive 'Shared Documents', but I could not able to retrieve these files from postman/using Http client. Passing a valid access token and below are the permission I have. enter image description here

Here is the Graph API using to get the file /sites/{site-id}/drive/root:/{item-path}

Docs

It's returning 404 not found error with message 'The resource could not be found.'

Not sure what I am missing. Your help will be greatly apprieciated. Thanks in advance.

Upvotes: 1

Views: 1044

Answers (1)

Michael Han
Michael Han

Reputation: 3655

From the error message, looks like the endpoint url you used is not correct. Suppose you have a file called test.docx in 'Shared Documents' in SharePoint site. You should get the file like this:

https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/test.docx

If the file is in a subfolder, you should get the file like this:

https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/folder1/test.docx

Upvotes: 1

Related Questions