microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

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

Open
#2,888 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Needs investigation
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied SearchWithQ example against Microsoft Graph .NET SDK 5.76, then compare it with the working Drives[_drive.Id].Items["root"].Children.GetAsync filter. Investigate the behavior of Root.ItemWithPath(path).SearchWithQ(q); done means identifying and documenting the cause or confirming a specific fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.