microsoftgraph / microsoftgraph/msgraph-sdk-dotnet
SearchWithQ doesn't work but I can't say if it's a bug
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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