How to get the file inside the folder on ondrive in ms graph?

Ken Martos 36 Reputation points
2022-05-03T20:16:40.22+00:00

I want to get the file inside the folder in ms graph but this api

https://graph.microsoft.com/v1.0/me/drive/root/children/01DVBENIQUUW6YWJUFF5GJGN7HV36UOU4B/items

is not working at all, what is the correct api?

here is the file and folder that is being retrieve with just this api

https://graph.microsoft.com/v1.0/me/drive/root/children

198643-files.jpg

I hope anyone could help be getting the items from the folder using its ID

Microsoft 365 and Office SharePoint Development
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 46,371 Reputation points
    2022-05-04T02:13:45.66+00:00

    Hi @Ken Martos

    You just need to list the children inside the folder.

    https://graph.microsoft.com/v1.0/me/drive/items/{item id of the folder}/children  
    

    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.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Shivam Dhiman 6,081 Reputation points
    2022-05-04T10:25:21.357+00:00

    Hi @Ken Martos

    To get the file inside the folder on onedrive using Graph API please follow below steps

    Step 1: To get the Folder-Id, use this Graph API endpoint https://graph.microsoft.com/v1.0/me/drive/root/children
    198841-folderid1.png

    Step 2: Now to get files inside that folder use this Graph API endpoint https://graph.microsoft.com/v1.0/me/drive/items/{items-id}/children
    Note: Put the Folder-id which we got in last step in-place of items-id in above endpoint
    198822-driveitem1.png

    Step 3: Now use Id which we got in Step 2 and replace items-id in give endpoint to get that particular file in folder
    198775-item1.png

    Please refer to this document for more details.

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


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.