Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine NOT filter in MS Graph API

I want to search graph API users for everyone whos name does not start with some value

I tried

https://graph.microsoft.com/v1.0/users?$filter="NOT startswith(displayName,'J')"
https://graph.microsoft.com/v1.0/users?$filter=not(startswith(displayName,'J'))

But I get

Invalid filter clause

Is there any way to achieve this?


I actually need to do this in C#, where I run into the same issue - I wonder if there is a way of specifying NOT STARTSWITH using the SDK?

string filter = String.Format("startswith(displayName,'J')");
List<QueryOption> options = new List<QueryOption>
{
    new QueryOption("$filter", filter)
};
var users = await graphClient.Users
    .Request(options)
    .Top(500)
    .GetAsync();
like image 387
Bassie Avatar asked Oct 19 '25 16:10

Bassie


1 Answers

I'm afraid this type of filter is not supported by users (or any other Azure AD resources). From the documentation:

The following $filter operators are not supported for Azure AD resources: ne, gt, ge, lt, le, and not.

like image 61
Marc LaFleur Avatar answered Oct 21 '25 06:10

Marc LaFleur



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!