Get the Group Id using Group mail or Group Name

Sameer Bhat 126 Reputation points Microsoft Employee
2022-09-06T11:06:57.007+00:00

Hi Team,

I want to know how to get the group id using group mail or group name in C#. I was trying to get group details using Microsoft graph Api, but it seems it takes only group-id as parameter.
https://graph.microsoft.com/v1.0/groups/{group-id}

I don't have group id; I have group email or group name. How to get group id without searching in entire org using below query
https://graph.microsoft.com/v1.0/groups

Thanks,
Sameer

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. RajeshKumarMSFT 1,976 Reputation points Microsoft External Staff
    2022-09-06T11:43:56.113+00:00

    Hi @Sameer Bhat ,

    Hope you are doing well,

    Using Graph API C# We can get the Group ID Details by passing Group Email/Displayname

    Please find the below sample code

    var groups = await graphClient.Groups  
    	.Request()  
    	.Filter("mail eq 'GroupEmail'")  
    	.Select("id,displayName")  
    	.GetAsync();  
    

    With the Below Graph API endpoint we can get Group ID Details

    https://graph.microsoft.com/v1.0/groups?$filter=mail eq 'XXXXXXXXXXXXXXXXXXXX'&$select=id,displayName

    238217-image.png

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

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.