Skip to content

SearchWithQ doesn't work but I can't say if it's a bug #2888

@Moreno-Borsalino

Description

@Moreno-Borsalino

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions