Create a Security Group using Graph API with Service Principal as an Owner

Nagesh Joshi 21 Reputation points
2021-09-10T16:42:47.2+00:00

I was trying to create a security group as mentioned in the below link - example 2
https://learn.microsoft.com/en-us/graph/api/group-post-groups?view=graph-rest-1.0&tabs=http

I am able to create a security group with the {user} as an owner to the newly created group. However, when I am trying to create a new group with the service principal as an owner it is failing. Is there a way with which I can create a security group with the service principal as an owner to it in a single API?

I have tried with the following approach as well:
"owners@odata.bind": [
"https://graph.microsoft.com/v1.0/servicePrincipals/00964c82-a7c2-4675-bbed-54bcf16328b3"
]

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

Accepted answer
  1. CarlZhao-MSFT 39,101 Reputation points
    2021-09-13T02:45:42.377+00:00

    Of course can create group in a single request and set the service principal as the owner of the group, and I think the method you tried in the question is correct, my test results:

    131394-image.png

    131442-image.png

    You can try to call the api in Graph Explorer and tell me the result.


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    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.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Nagesh Joshi 21 Reputation points
    2021-09-13T03:09:12.823+00:00

    Thank you for your prompt response.
    I am getting the following error:
    {
    "error": {
    "code": "Request_ResourceNotFound",
    "message": "{Resource 'Object ID of SPN}' does not exist or one of its queried reference-property objects are not present.",
    "innerError": {
    "request-id": "bcb7957e-c847-4934-a33e-de981cc94e14",
    "date": "2021-09-13T02:59:00",
    "client-request-id":"d5827179-30ad-c7d5-7718-2f8a0e503432"
    }
    }
    }


  2. Nagesh Joshi 21 Reputation points
    2021-09-13T07:55:17.82+00:00

    Thanks a lot @CarlZhao-MSFT .
    It is working properly now.

    0 comments No comments