Search code examples
azure-active-directorymicrosoft-graph-apionedrive

How to get the UniqueId of a Onedrive (for business) file?


I want to get the UniqueId of my files in one drive. If you select a file and then download it, the download link contains the unique id. Additionally, if you share one of your word, powerpoint, excel and similar files with only specific people, the sharable link contains the uinque id but not for other files like photos and videos for which only the path of the file is seen in the link.

Is there anyway to get the unique id for photos and videos like it could be gotten for word and excel files? Is there any API that allows me to do so?

Thanks for answeiring.


Solution

  • Try this:

    https://graph.microsoft.com/v1.0/me/drive/items/<Item ID>/children?$select=id,name
    

    Result:

    I have 3 files under a folder, so this is my request and result: enter image description here enter image description here

    If you are not sure about your folder item id, use the request below to get all item id under root:

    https://graph.microsoft.com/v1.0/me/drive/items/root/children?$select=id,name
    

    Result:

    enter image description here enter image description here

    More about this, see here.