msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

Items GetAsync with Filter on Name, expect 1 result but get 0

Open AcidRaZor opened this issue 1 year ago • 2 comments

I've found that using filter on a folder (in this case my root / Shared Documents in SharePoint) it doesn't return the folder


var folderSearch = await serviceClient!
            .Drives[drive.Id]
            .Items
            .GetAsync(cfg => cfg.QueryParameters.Filter = "name eq 'myfolderthatexists'");

Since my folder has 200+ items in it, I used PageIterator (since I saw ONextDataLink being returned) and saw I had to page to the item before it returns?

The expectation of Filter (at least in my opinion) should return that driveitem only

I don't mind using PageIterator, as soon as I detect the Item I just return false to stop it. I'm just wondering why the filter returns empty pages until it's on the page it expects?

AcidRaZor avatar Oct 07 '24 00:10 AcidRaZor

Thanks for raising this @AcidRaZor

Are you by any chance able to replicate this on the Graph Explorer? This sounds like an issue with the API returning empty responses for some of the pages.

andrueastman avatar Oct 07 '24 07:10 andrueastman

@andrueastman Thanks for the reply, and yes I can (I tried both to make sure I wasn't going insane)

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('snip')/items",
    "@odata.nextLink": "https://graph.microsoft.com/v1.0/drives/snip/items?$filter=name+eq+%27shitzandgigs%27&$skiptoken=snip",
    "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET drives('<key>')/items?$select=audio,bundle",
    "value": []
}

It returns the odata.nextLink, and as I keep paging, it only returns data for the filtered item on the page it thinks it is on as if I'm querying the data without a filter.

AcidRaZor avatar Oct 07 '24 21:10 AcidRaZor