Share via

Getting 404 from GraphAPI although the sharepoint document can be open and edit

GSH-1402 110 Reputation points
2025-02-12T09:47:18.8233333+00:00

This was an issue faced by one of the users who uses my Add-in.

The user has a SharePoint document that has been shared with him and he can Open the document and edit as well. But when he tries to open the Add-in it gives 404 error.

I investigated this issue with him and the issue was, below endpoint I use to get document metadata returns 404 for his case.

/sites/{site_id}/drive/root:/{document_relative_path}	

The site_id and the document path is correct. This issue only happens with that user, for other users the add-in works fine for SharePoint documents.

Any idea to why this only happens to that user and is there any permission that needed to be set from his end.

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments

Answer accepted by question author

Ling Zhou_MSFT 23,690 Reputation points Microsoft External Staff
2025-02-13T02:40:37.91+00:00

Hi @GSH-1402,

Thanks for reaching out to us. We are very pleased to assist you.

According to the information you provided and the research I have done, I may understand that you try to get the files in a site's default Shared Document library. If there is anything wrong, please correct me.

If there is not anything wrong, then we need to check the following areas to troubleshoot the problem:

1.Document Location & Site ID and Document Path:

I know you've probably checked this many times, but I'd still recommend checking the site id and document path again (if the file is in a folder, then the path should include the folder). Confirm that the document is indeed located at the specified path. It might have been moved or deleted.

2.Permissions:

Verify that the user in question have the necessary permissions to access the document. Even if you have access to the file through other means, the API call requires specific permissions. According to this official documentation, user may need these permissions to use the request:

User's image

3.Permissions for documents in SharePoint:

Please try removing the user's SharePoint access to the document and then re-granting it. Sometimes regranting the permissions will solve the problem.

4.Gets all the documents in the Shared Document library.

If the problem still exists, try using the following request to get all the files in the Shared Document library and see if the returned result contains the target document.

YAMLCopy

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

If you have any questions, please do not hesitate to contact me.


If the answer is helpful, please click "Accept Answer" and kindly upvote it. It will be beneficial to more community members reading here. Your contribution will be highly appreciated.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.