Code: itemNotFound Message: The resource could not be found.

AB 1 Reputation point
2022-08-12T14:35:43.427+00:00

According to the documentation https://learn.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0&tabs=http

Retrieve the metadata for a driveItem in a drive by file system path or ID. item-id is the ID of a driveItem. It may also be the unique ID of a SharePoint list item.

Using the following request
https://graph.microsoft.com/v1.0/me/drive/items/01X7C23GQWT5UNU3YQ6FDICAEOASOWQ5LW?select=sharepointids

Response

{  
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('bdab55ad-2ff1-44f3-adb2-bded7f47379a')/drive/items/$entity",  
    "@odata.etag": "\"{DA689F16-106F-46F1-8100-8E049D687576},6\"",  
    "sharepointIds": {  
        "listId": "15e4036c-1f5c-4e28-a59d-c702407a5ba4",  
        "listItemId": "4",  
        "listItemUniqueId": "da689f16-106f-46f1-8100-8e049d687576",  
        "siteId": "92f9d935-71bc-4eab-868b-32dfbc1a460c",  
        "siteUrl": "REMOVED",  
        "tenantId": "ff732f75-0680-43aa-be16-a97c2520f0c4",  
        "webId": "3b556987-0954-417d-829f-76ab02dd1d2f"  
    }  
}  

Based on the documentation I should be able to make the same request using the "listItemUniqueId"?

Request:
https://graph.microsoft.com/v1.0/me/drive/items/da689f16-106f-46f1-8100-8e049d687576/

Response

{  
    "error": {  
        "code": "itemNotFound",  
        "message": "The resource could not be found.",  
        "innerError": {  
            "date": "2022-08-12T14:29:13",  
            "request-id": "fdf19ff6-96d2-44b7-8bde-ad269dd74301",  
            "client-request-id": "882ce395-df9d-56c6-31d7-7684fb6b27e2"  
        }  
    }  
}  

The above requests were made using the https://developer.microsoft.com/en-us/graph/graph-explorer

I've also tried both with an application and still the same results. Has there been any changes?

If this is a backend issue, should it be returning itemNotFound, I don't think you should be retrying on this.
https://learn.microsoft.com/answers/questions/257165/itemnotfound-for-file-that-does-exist.html

In the above example, this is for OneDrive, but have seen it SharePoint Sites as well

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,524 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. HarmeetSingh7172 4,811 Reputation points
    2022-08-12T17:08:48.483+00:00

    Hi @AB

    Hope you're doing well.

    As per my research and understanding, you can't use listItemUniqueId as an item-id in https://graph.microsoft.com/v1.0/me/drive/items/{item-id}/ endpoint.
    However, you can always pass a item-id of an item present in SharePoint List (in above endpoint). Please note that Items in a SharePoint document library can be represented as a listItem or driveItem resource.

    For listing the items of a drive, use this endpoint- https://graph.microsoft.com/v1.0/me/drive/root/children
    For listing the children of a driveItem, say a folder- https://graph.microsoft.com/v1.0/me/drive/items/{item-id}/children
    Furthermore, you can replace item-id of folder in above endpoint by item-id of a residing file using Graph API response.

    Hope this helps.
    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

  2. AB 1 Reputation point
    2022-08-14T16:31:46.953+00:00

    Hi @HarmeetSingh7172
    Thanks for getting back to me. Unless I've missed something the documentation has this
    230948-image.png

    This was working previously around 8 weeks ago off the top of my head, I made changes in our application to use this id and it worked fine.

    0 comments No comments