Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering Users in MSGraph

I'm trying to filter users by attributes in Microsoft Graph API. Essentially trying to get a list of users that have a given jobTitle assigned.

For example, https://graph.microsoft.com/v1.0/users?$filter=jobtitle eq 'ACCOUNT EXECUTIVE' returns a list of users.

My requirement is to query for users that do not have a JobTitle.

Tried https://graph.microsoft.com/v1.0/users?$filter=jobtitle ne null and got the following message.

{
    "error": {
        "code": "Request_UnsupportedQuery",
        "message": "Unsupported property filter clause operator 'NotEqualsMatch'.",
        "innerError": {
            "request-id": "c9b290bf-2902-4b79-b35b-0f5d251ad80b",
            "date": "2017-09-14T11:18:52"
        }
    }
}
like image 753
Jay Paddy Avatar asked Sep 14 '17 11:09

Jay Paddy


People also ask

What is https graph Microsoft COM?

Microsoft Graph is the gateway to data and intelligence in Microsoft 365. It provides a unified programmability model that you can use to access the tremendous amount of data in Microsoft 365, Windows, and Enterprise Mobility + Security.

How can multiple requests be executed in a batch request?

Batching is a way of combining multiple requests into a single HTTP request. The requests are combined in a single JSON payload, which is sent via POST to the \$batch endpoint.


2 Answers

$filter=department ge '!' appears to be a workaround here.

like image 103
Toucan Jam Avatar answered Jan 01 '23 10:01

Toucan Jam


According to this Git Issue, I don't think it's supported: https://github.com/microsoftgraph/microsoft-graph-docs/issues/239 (it eventually just revolves around finding rooms)

There is no way to filter the users collection for entities with surname equal to null or empty string. The value of the filter must be between 1 and 64 characters as documented here: https://msdn.microsoft.com/en-us/Library/Azure/Ad/Graph/api/entity-and-complex-type-reference#userentity - marych Apr 26, 2016

The lack of null filtering is due to the way users are indexed. We can't efficiently retrieve users with an indexed property unset. There are no plans to change that. - marych May 13, 2016

like image 22
Ryan Taite Avatar answered Jan 01 '23 10:01

Ryan Taite