Include search in Microsoft graph query C#

Viewed 41
1 Answers

Try this code pls:

var queryOptions = new List<QueryOption>()
{
    new QueryOption("$count", "true"),
    new QueryOption("$search", "\"displayName:tiny\"")
};
var res = await graphClient
    .Users.Request(queryOptions)
    .Header("ConsistencyLevel", "eventual")
    .Filter("endswith(mail,'contoso.com')")
    .OrderBy("userPrincipalName")
    .Select("id,displayName,mail")
    .Top(999)
    .GetAsync();

When we follow the official code snippet, we should use .Search() but it will meet exception:

enter image description here

Then let's see github issue here, and we can set search parameter into query option.

Related