Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply an equality filter to a Users request?

I'm trying to make a call to the MS Graph Users API using C# and the GraphServiceClient. I'm trying to filter by Mail but no matter what format I try, it gets rejected due to an invalid query. I've tried all the examples I've found on the interwebs but I can't seem to find one that uses the service client to filter users by equality.

I've tried the following in Filter.

$"eq('Mail', '{email}')", $"equal('Mail', '{email}')", $"equals('Mail', '{email}')", and $"'Mail' eq '{email}'"

await _graphClient
    .Users
    .Request()
    .Filter(filter)
    .GetAsync();

I did find a way to filter users where my tenant is the issuer but I need to be able to also search for invited users as well.

var filter = $"Identities/any(id:id/Issuer eq '{TenantName}' and id/IssuerAssignedId eq '{emailAddress}')";

Removing the equality check on the TenantName makes it an invalid filter.

What am I doing wrong here; is it possible?

like image 975
ChiefTwoPencils Avatar asked Oct 27 '25 15:10

ChiefTwoPencils


1 Answers

Here is the filter in my code for your reference:

var response = await graphClient.Users.Request().Filter("mail eq '[email protected]'").GetAsync();
like image 172
Hury Shen Avatar answered Oct 30 '25 08:10

Hury Shen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!