Filtering by employeeType: How to apply le or ge on a string type? How to set the ConsistencyLevel header?

Hagen 30 Reputation points
2023-07-31T08:49:41.95+00:00

Hello,

I would like to filter a users request by EmployeeType where the employee type is not null. Something like this:

var resp = await _gsclient.Users.GetAsync((rc) =>
                {
                    rc.QueryParameters.Select = new string[]
                    {   "id",
                    "userPrincipalName",
                    "employeeType",
                    "accountEnabled"
                    };
                    rc.QueryParameters.Filter = "employeeType not eq null";
                });

According to https://learn.microsoft.com/en-us/graph/api/resources/user?view=graph-rest-beta eq on null values is not supported for employeeType, whereas eq, ne, not , ge, le, in, startsWith is supported. So I had the idea to use 'ge' instead like

var resp = await _gsclient.Users.GetAsync((rc) =>
                {
                    rc.QueryParameters.Select = new string[]
                    {   "id",
                    "userPrincipalName",
                    "employeeType",
                    "accountEnabled"
                    };
                    rc.QueryParameters.Filter = "employeeType.length ge 1";
                });

That length property is just an assumption. I have no idea how to apply ge or le on a string type. Greater or equal than what?

Additional question: while searching for a hint, I found in https://learn.microsoft.com/en-us/answers/questions/377469/ms-graph-filter-users-using-employeetype that filtering using employeeType only works if the count parameter is added and I would have to set the ConsistencyLevel header with the value of eventual. How to set this header when using the SDK?

Thank you.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,049 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.