Graph API assigned label filtering

Ricardo Matos 0 Reputation points
2024-01-31T15:55:13.8766667+00:00

Hello everyone! I'm making a graph API call the following way:https://graph.microsoft.com/beta/users/{user_ID}/ownedObjects/microsoft.graph.group$select=id,displayname,createdDateTime,assignedLabels&$count=true&$filter=assignedLabels/any(label : label/displayName eq 'TEST') In essence I'm trying to fetch all the groups that contain the label "Test" What I would expect to get back as a reply is this:

 "@odata.context": "https://graph.microsoft.com/beta/$metadata#groups(id,displayName,createdDateTime,assignedLabels)",

    "value": [

        {

            "id": "[GUID]",

            "displayName": "TEST",

            "createdDateTime": "2023-02-04T15:24:05Z",

            "assignedLabels": [

                {

                    "labelId": "[GUID]",

                    "displayName": "TEST"

                }

            ]

        }

However I'm getting the following reply back:

{

    "error": {

        "code": "Request_UnsupportedQuery",

        "message": "Unsupported query on property 'AssignedLabel'.",

        "innerError": {

            "date": "2024-01-31T15:31:13",

            "request-id": "8f3de165-3c0b-4ff2-84ac-95f0ab042227",

            "client-request-id": "8f3de165-3c0b-4ff2-84ac-95f0ab042227"

        }

    }

}

Any idea why this filter operation is invalid? Thank you!

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

1 answer

Sort by: Most helpful
  1. Vasil Michev 100.2K Reputation points MVP
    2024-01-31T17:27:09.79+00:00

    Not every property if filterable in the Graph. Generally speaking, you should consult the documentation each time you plan to use a filter, for example the article on Group properties shows assignedLabels as not filterable: https://learn.microsoft.com/en-us/graph/api/resources/group?view=graph-rest-1.0#properties

    0 comments No comments