Get driveItem without absolute path

Yucra López, Carlos Enrique 1 Reputation point
2022-09-05T09:36:13.19+00:00

Hello everyone.
I'm trying to get an driveItem without telling all the path for example the call would be like : GET https:graph.microsoft.com/v1.0/sites/<id_site>/<idItem> and returning all data of the item requested.

Does exist any solution to my question?

Thanks

Best regards.

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

1 answer

Sort by: Most helpful
  1. Vasil Michev 96,836 Reputation points MVP
    2022-09-05T09:54:13.103+00:00

    As long as you have the itemId, there is no need to specify the path. For example, this is how to get a specific item within my ODFB site collection:

    GET https://graph.microsoft.com/v1.0/me/drive/items/01BATTRZNBUNZS4552UNF23DBJY5IMLUJH  
    

    For SPO site collections it's a bit more complicated, as you need to provide the siteId and listId first, but items within the library can be enumerated by simple incremental numbers. Here's an example:

    GET https://graph.microsoft.com/v1.0/sites/tenant.sharepoint.com,33824aad-cb6e-464f-8a84-ccc371607728,4cc0fca1-f010-4e3f-b8b8-136f1d6fa200/lists/3fdbd1c5-fc3b-4b77-9dc9-625d61b859b6/items/55  
    

    where I'm getting the 55th item in the Shared Documents library of the default site collection.

    0 comments No comments