-
Notifications
You must be signed in to change notification settings - Fork 263
Description
I've tried every way to make SearchWithQ work to search for a file on OneDrive but it never finds anything. Yet I followed the example in Microsoft.Graph.DotnetCore.Test.
Has anyone managed to use it to search for files on OneDrive?
I'll start by saying that I'm using Graph version 5.76.
The following example works, it tells me if there is a folder on the root of OneDrive:
var name = "myDocFolder";
var _drive = await _graphServiceClient.Me.Drive.GetAsync();
var driveRoot = await _graphServiceClient.Drives[_drive.Id]
.Items["root"].Children.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = $"name eq '{name}'";
});
var folderExist = driveRoot != null && driveRoot.Value.Count == 1 && driveRoot.Value[0].Folder != null;
instead the following code that uses SearchWithQ doesn't work, it doesn't find anything.. but the file exists! :
var string path = "/myDocFolder";
var q = "data.zip";
var _drive = await _graphServiceClient.Me.Drive.GetAsync();
var searchResult = await _graphServiceClient.Drives[_drive.Id].Root.ItemWithPath(path).SearchWithQ(q)
.GetAsSearchWithQGetResponseAsync();
var files = searchResult?.Value;
Do you have any explanation or solution?