Search code examples
microsoft-graph-api

How to search the group by the DisplayName using Microsoft Graph?


According to the document, I can list the Office 365 Groups by using the following Graph API:

GET https://graph.microsoft.com/v1.0/groups

I have a C# Web application, and there is a input for searching by the Group DisplayName. Any idea how to query groups based on the DisplayName?

I have tried the following URL: https://graph.microsoft.com/v1.0/groups?$search="displayName:Test" in the MS Graph Explorer which didn't work.

I get the following error.

{
"error": {
    "code": "Request_UnsupportedQuery",
    "message": "This query is not supported.",
    "innerError": {
        "request-id": "35d90412-03f3-44e7-a7a4-d33cee155101",
        "date": "2018-10-25T05:32:53"
    }
}

Any suggestion is welcomed. Thanks in advance.


Solution

  • According to your description, I assume you want to search the Group by the DisplayName using the search parameters.

    Based on this document, we can currently search only message and person collections. So we couldn't use the search parameter.

    We can use the filter query parameter to search the Group by DisplayName. For example, we can search the groups whose displayName is start with 'Test',the request url like this:

    https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName,'Test')