Reputation: 485
Which query should I use in Microsoft Graph (latest version) to get all users which email contains a specific character sequence?
I.E:
users.Where( x => x.Contains( str));
emails that ends with a sequence are still acceptable, but the first way is preferred.
users.Where( x => x.EndsWith( str));
It is preferrable to get as response a Json with an array of users rather than querying each one individually.
Upvotes: 1
Views: 577
Reputation: 33094
Microsoft does not support contains
, nor does it support LINQ style queries. As result, it isn't possible to filter user
resources based on a given SMTP domain. It's also possible for a user to have more than one email address associated with the record (userPrincipalName
, mail
, proxyAddresses[]
).
Your best bet would be to pull down the user
records with the relevant properties and process them offline:
/v1.0/users/?$select=id,displayName,userPrincipalName,Mail,proxyAddresses
If this is something you need to do regularly, you could store them and use /delta
queries to pull down only records that have changed to keep the two in sync:
/v1.0/users/delta?$select=id,displayName,userPrincipalName,Mail,proxyAddresses
Upvotes: 1