List group owners API

Priyanka Sharma 0 Reputation points Microsoft Employee
2024-09-27T07:38:28.35+00:00

Hi Team,

I am trying to get owner for a security group using service group id with below request:

https://graph.microsoft.com/v1.0/groups/{group-id}/owners

And it seems to be returning empty response each time. I checked for multiple security groups.

Sample response:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects",
    "@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET groups('<guid>')/owners?$select=deletedDateTime",
    "value": []
}
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,943 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 105.1K Reputation points MVP
    2024-09-27T09:06:28.3733333+00:00

    It's not mandatory for a group to have an owner, so you might just be running into ownerless groups. This filter can help you get only the ones with at least one owner:

    GET https://graph.microsoft.com/v1.0/groups?$select=id,displayName&$filter=owners/$count ne 0&$count=true
    

    Keep in mind that the above is an advanced query, so make sure to add the necessary header.

    Other than that, check the permissions you're running with.

    0 comments No comments

  2. Yakun Huang-MSFT 4,555 Reputation points Microsoft Vendor
    2024-09-27T09:51:43.58+00:00

    Hi @Priyanka Sharma

    After testing, the endpoint works well enough to list the owners of the group, and the test results are as follows:

    Screenshot 2024-09-27 094855

    If the value you get is empty, possibly because the group you are querying does not have an owner, you can try the endpoint to add an owner to the group before querying.

    Hope this helps.

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

    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.