GET /sites/{site-id}/drive/root:/{item-path} stopped working

Angel Escamilla 20 Reputation points
2023-09-28T16:53:23.66+00:00

I am using a an API call to find a file in one of our SharePoint sites, I made a flow that was running fine until Monday of this week. The API returns the "itemNotFound" error.

I have no idea what's wrong, if I call the search function the file comes back fine, but if I specify the item path then I get the error... completely at a loss what happened and how to fix it. We are using this system to creat automatic files on the server so I really need to get this fixed as soon as possible.

Search API that works fine:

https://graph.microsoft.com/v1.0/sites/{*site id removed for privacy*}/drive/root/search(q='testfile.docx')

response (abreviated):

			"createdDateTime": "2023-09-27T13:21:24Z",
            "id": "0124G6SZYNCIZEZOC6DVELGBOBQTHBRUUG",
            "lastModifiedDateTime": "2023-09-27T13:22:06Z",
            "name": "testfile.docx",

Search API that returns 404 error:

https://graph.microsoft.com/v1.0/sites/{*site id removed for privacy*}/drive/root:/Shared%20Documents/testfile.docx

response:

{
    "error": {
        "code": "itemNotFound",
        "message": "The resource could not be found.",
        "innerError": {
            "date": "2023-09-28T16:51:18",
            "request-id": "40aeed24-7698-437e-8ce3-9a62369fbd6a",
            "client-request-id": "a9ce4951-f6af-7ee7-a8a5-a77083a88717"
        }
    }
}

I created a file at the root of the Shared Documents on SharePoint to avoid having an issue with a long path, still the same issue.

I appreciate if you can shed some light on this.

Regards,

Angel

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,289 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,837 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 36,171 Reputation points Microsoft Vendor
    2023-09-29T07:39:45.36+00:00

    Hi @Angel Escamilla,

    Per my test, I can reproduce your issue like following

    User's image

    After doing some research, I found that /sites/{site-id}/drive is to access the default drive (document library) for the given site. We don't need to add Shared%20Documents in the path. The api is to get the items in subfolders of Shared%20Documents. I created a folder in the Shared%20Documents named test and a docx file named test.docx in the folder. Then we can use the api like following

    User's image

    And we are unable to get the files in the root path of the library, for example I created a file called test.txt in Shared Document. The api will also return 404. For these items you can get tem by following api

    GET /sites/{site-id}/lists/{list-id}/items/{item-id}/driveItem
    
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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