4

I am using the .net SDK. Trying to filter a large list with Microsoft Graph,

My query works fine using .Items.Request().Expand("fields").GetAsync(); However, if I add a filter, it doesn't work as expected.

I have tried two approaches :

  1. Add .Expand("fields").Filter("fields/Archived eq false").GetAsync(); That works, but returns all the list items without filtering.

  2. Add .Expand("fields($filter=Archived eq false)").GetAsync(); This does not work - it gives me an error that expand, select, and filter are the only allowed queries.

What does work is ("fields($select=Archived)"), but of course, no filtering is done.

So how are we to query large lists using Microsoft Graph?

0

2 Answers 2

4

You need to quote the value you pass into your filter: Fields/Archived eq 'false' (note the 's):

var result = graphClient
    .Sites["root"]
    .SiteWithPath("siteId")
    .Lists["listId"]
    .Items
    .Request()
    .Expand("Fields")
    .Filter("Fields/Archived eq 'false'");
Sign up to request clarification or add additional context in comments.

Comments

1

After too much research on this issue i found below solution and its working fine for me:

To Filter you need to add Header parameter as follow: Prefer : HonorNonIndexedQueriesWarningMayFailRandomly

And Graph api will be as follow: &$filter = Fields/Archived eq False

1 Comment

Alternatively you can add the column in SharePoint as an index, this will improve performance rather than filtering against an un-indexed column support.microsoft.com/en-us/office/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.