Schema Extensions : "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'."

I'm currently building an application that requires me to retrieve users from the Graph API depending of a custom property, in that case, extoe82ql2v_test/companyName but so far, the API responded with Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'."

The request to retrieve the extension :

https://graph.microsoft.com/v1.0/schemaExtensions?$filter=id eq 'extoe82ql2v_test'

The result :

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#schemaExtensions",
    "value": [
        {
            "id": "extoe82ql2v_test",
            "description": "Extend data for users",
            "targetTypes": [
                "User"
            ],
            "status": "InDevelopment",
            "owner": "d9a847ce-ca03-4779-88d6-c7e4f98297fe",
            "properties": [
                {
                    "name": "companyName",
                    "type": "String"
                },
                {
                    "name": "managerMail",
                    "type": "String"
                },
                {
                    "name": "arrivalDate",
                    "type": "DateTime"
                },
                {
                    "name": "expiryDate",
                    "type": "DateTime"
                }
            ]
        }
    ]
}

The request to retrieve the users depending of extoe82ql2v_test/companyName :

https://graph.microsoft.com/v1.0/users?$select=extoe82ql2v_test,givenName,surname,mail,mobilePhone,department,companyName,accountEnabled&$filter=extoe82ql2v_test/companyName eq 'test'

The result :

{
    "error": {
        "code": "Request_UnsupportedQuery",
        "message": "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'.",
        "innerError": {
            "date": "2020-07-24T20:46:51",
            "request-id": "639b8131-70dd-4436-b624-88167fe105eb"
        }
    }
}

The same query with the Microsoft Graph .NET SDK :

var res = await _graphClient.Users.Request()
    .Select($"extoe82ql2v_test,givenName,surname,mail,mobilePhone,department,companyName,accountEnabled")
    .Filter($"extoe82ql2v_test/companyName eq 'test'").GetAsync()

I don't understand what the issue is as I followed what the official documentation said about filtering custom properties

Any help is greatly appreciated

Edit : Here is how $select without a $filter looks like

Request : https://graph.microsoft.com/v1.0/users?$select=givenName,surname,mail,mobilePhone,department,companyName,accountEnabled,extoe82ql2v_test

Response :

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(givenName,surname,mail,mobilePhone,department,companyName,accountEnabled,extoe82ql2v_test)",
    "value": [
        {
            "givenName": "Antoine",
            "surname": "D",
            "mail": "[email protected]",
            "mobilePhone": null,
            "department": null,
            "companyName": null,
            "accountEnabled": true,
            "extoe82ql2v_test": {
                "@odata.type": "#microsoft.graph.ComplexExtensionValue",
                "expiryDate": "2020-12-31T00:00:00Z",
                "arrivalDate": "2020-07-22T00:00:00Z",
                "managerMail": "[email protected]",
                "companyName": "test"
            }
        }
    ]
}

Edit 2: I successfully filtered the users with another custom attributes, extoe82ql2v_test/managerMail, it's progress but I still need to apply a filter on extoe82ql2v_test/companyName and make it works

Edit 3: Filtering on extoe82ql2v_test/expiryDate and extoe82ql2v_test/arrivalDate also works, both of these attributes are useless to filter but at least I know they work. As for extoe82ql2v_test/companyName, I wonder if it is because this attribute exists in both the schema extensions and the User Graph object ?


I just faced the same problem and made it work by adding "$count=true" in the query parameters.

I also noticed it seems to need ConsistencyLevel=eventual in the request header.

For example:

  • https://graph.microsoft.com/v1.0/users?$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName

Bad Request - 400 - 146ms

{
 "error": {
   "code": "Request_UnsupportedQuery",
   "message": "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'.",
   ...
}
  • https://graph.microsoft.com/v1.0/users?$count=true&$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName (with header ConsistencyLevel=eventual)

OK - 200 - 404ms

\o/

(I got the hint by looking at this question Microsoft Graph API cannot filter /users by companyName?)