Angel
Angel

Reputation: 81

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

I am using 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 create automatic files on the server so I really need to get this fixed as soon as possible.

Search API that returns 404 error:

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

Graph 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"
        }
    }
}

If I try a search query that works fine and the file is found:

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

Graph response (abreviated):

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

So I don't believe is related to Permissions missing.

The weirdest part is that it was working fine last week, and this week it simply just broke.

Upvotes: 0

Views: 2152

Answers (1)

Angel
Angel

Reputation: 81

After posting the question in the Microsoft Q&A I got the followin: /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.

So the API GET call should look like graph.microsoft.com/v1.0/sites/{site id removed for privacy}/drive/root:/testfile.docx now "Shared%20Documents" should be added.

Link to full answer on Microsoft Learn site

Upvotes: 1

Related Questions