Home > Back-end >  How to retrieve the parent-item-id in MS graph
How to retrieve the parent-item-id in MS graph

Time:06-04

I want to use this query using the MS office api, it looks like this:

POST /sites/{site-id}/drive/items/{parent-item-id}/children

I can not seem to find the parent-item-id of the parent folder, and it only work when I use root as id. I tried to find the ids of all folders using:

https://graph.microsoft.com/beta/sites/{site_id}/drive/root/children

This returns a list of all folders in root, along with their ids. However, when I replace root by a folder id I get no results, only Resource not found for the segment.

How should I go about finding the folder id? I already tried the method above and looking at the share link of the folder. Both do not work.

CodePudding user response:

According to this source it is possible to locate folder in your onedrive using the following syntax:

GET /drives/{drive-id}/root:/{path-relative-to-root}:/children

This finally worked.

CodePudding user response:

You can do a GET call on /sites/{site-id}/drive/items/ and find the parentID of all the items that you intentded to find

  • Related