0
votes

I have problem with graph API. I'm making search component in React. Of course there can be many files with same name so I need to display path to it also. Problem is with this endpoint:

https://graph.microsoft.com/v1.0/me/drive/root/search(q='book')

I noticed that when I'm searching for all drive elements I receive path to file. But when I'm using /me/drive endpoint to search for only my files there is no path in parentReference. The only option to get path is making second request:

https://graph.microsoft.com/v1.0/me/drive/items/{parent_reference_id}

Is there any solution for this? I tried expanding parentReference but it's saying that it's not supported.

1

1 Answers

0
votes

When ever you try to get the path of an item you can use the /Items/{itemId} endpoint that gives the ParentReference property with the path in it.

https://graph.microsoft.com/v1.0/me/drive/Items/{Itemid}

enter image description here

In your case as you are searching for book file, pull the id from there and use the above query to get the path.