Best way to get group id from site id

Sanskaar Patni 0 Reputation points Microsoft Employee
2023-02-10T05:13:32.59+00:00

I am able to get the group id using graph filtering logic for mailNickname. Is this the best approach? Another workaround I found out was using proxyAddresses. Later, found out proxyAddresses doesn't always contains the SPO:SPOsiteId@SPOtenant

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
{count} votes

3 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,481 Reputation points Microsoft External Staff
    2023-02-10T06:42:48.0733333+00:00

    Hi @Sanskaar Patni

    Per my research, proxyAddresses is not recommended to retrieve group id. Some proxyAddresses of groups are not set, so we are unable to get the properties. You can refer to the following document

    User doesn't have the mailNickName or proxyAddresses attribute set

    Currently the best way to get group id is to filter by mailNickname or displayName. Please refer to the following api

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

    https://graph.microsoft.com/v1.0/groups?$filter=mailNickname eq 'Test'&$select=id


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

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Gopinath Chennamadhavuni 2,446 Reputation points
    2023-02-10T10:00:45.89+00:00

    Hi @Sanskaar Patni,

    Thanks for reaching out.

    To get the group details based on site id or name, please refer the below 2 approaches.

    I would recommend the solution 1 since for some of the groups proxyAddresses will not set.

    Solution1:

    Run the below graph api to get the SharePoint site associated group details:

    Solution2:

    Run the below graph Api to get the site details based on the site URL.

    Hope this helps.

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

    0 comments No comments

  3. Ioannis Gianko (Admin) 0 Reputation points
    2024-10-21T12:23:25.1366667+00:00

    You can get it from the SP site's drive

    https://graph.microsoft.com/v1.0/sites/siteID/drive?$select=owner

    And it's under the group object.

    0 comments No comments

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.