Reputation: 3746
I was following this documentation https://learn.microsoft.com/en-us/graph/aad-advanced-queries?tabs=csharp to run some graph query on AAD objects as follows:
await _graphServiceClient
.Users.Request()
.Request(new Option[] { new QueryOption("$count", "true") })
.Header("ConsistencyLevel", "eventual")
.Filter("endsWith(mail,'tenant.com')")
.GetAsync();
I see the following error:
What am I missing and how do I resolve the same?
Upvotes: 0
Views: 898
Reputation: 16004
I tried to reproduce the same in my environment and got the below results:
To retrieve the list of users with Mail-ID
, I executed the below query in Microsoft Graph Explorer:
GET https://graph.microsoft.com/v1.0/users?$count=true&$filter=endsWith(mail,'@tenant.com')
ConsistencyLevel:eventual
Response:
You can make use of the below sample CSharp code:
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var users = await graphClient.Users
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Filter("endsWith(mail,'@tenant.com')")
.GetAsync();
Upvotes: 1
Reputation: 16066
await _graphServiceClient
.Users.Request(new Option[] { new QueryOption("$count", "true") })
.Header("ConsistencyLevel", "eventual")
.Filter("endsWith(mail,'tenant.com')")
.GetAsync();
Upvotes: 1