Understanding api query better - $expand

OldButYoungDev 61 Reputation points
2022-10-29T14:06:02.27+00:00

So im totally new with msgraph api graph explorer.

I believe my question might be towards oData. Im not sure.

How can i understand the API better?

So i wanted to see the names of the items in my onedrive. so i tried using the below call:

https://graph.microsoft.com/v1.0/drives/xxx/list/items

I was not able to see the folders.

I had to do alot of googling and found a site where someone mentioned this below call:

https://graph.microsoft.com/v1.0/drives/xxx/list/items?$expand=driveItem

My question is, how was i basically suppose to know this 'driveItem' existed in the first place? When i called:
https://graph.microsoft.com/v1.0/drives/xxx/list/items

There was no indication there was a driveItem thing to expand.

What other 'things' are there besides driveItem that i can expand?

How can i see them all?

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

Accepted answer
  1. HarmeetSingh7172 4,811 Reputation points
    2022-10-31T02:15:22.383+00:00

    Hello @OldButYoungDev

    Thanks for reaching out!

    To list drives for a target user, please refer this List Drives documentation.

    Endpoint- GET /me/drives or GET /users/{user-id}/drives

    To list children of a Drive (driveItems), please refer this documentation. The below endpoints will first List children in the root of the current user's drive and post that you can select any ItemId and expand their children.

    Endpoint- GET /me/drive/root/children followed by GET /me/drive/items/{item-id}/children

    Hope this helps.

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

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Zehui Yao_MSFT 5,846 Reputation points
    2022-10-31T02:46:00.457+00:00

    Hi @OldButYoungDev , here is the documentation of microsoft graph api expand parameter you can refer to: https://learn.microsoft.com/en-us/graph/query-parameters#expand-parameter.
    Hope this helps, wish you all the best.

    255474-image.png


    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.

    0 comments No comments