0
votes

As it is documented, using the Microsoft Graph REST API you can Search the hierarchy of items for items matching a query.

This works fine, as expected when we using API based approach using postman : https://{xxxxxx}-my.sharepoint.com/_api/v2.0/me/drive/root/search(q='Test')

Same functionality when we want to use Microsoft graph client, and it produces error.

Eg :

await graphClient.Me.Drive.Search(searchText).Request().GetAsync();

Error :

Code: -1, Microsoft.SharePoint.Client.ResourceNotFoundException Message: Cannot find resource for the request microsoft.graph.search.

Note : Same graphClient search call works properly for OneDrive for personal but not work for oneDrive for Business.

1
Hi @Anand did you find anything useful ?Jonathan James

1 Answers

1
votes

According to your description, you want to search the DriveItems using MS Graph.

Based on your posted, you get the DriveItems in the root. However, you get the drive when you use the MS Graph.

We can use the follow code to get the DriveItems in the root.

await graphClient.Me.Drive.Root.Request().GetAsync();

However, refer to this document, the search query parameter is only support the message and person collections. So you can't use here.