I'm using Microsoft Graph API Beta version to add an application as owner of a group (I verified this is possible via Azure Console). The API I found for my case is this one: https://docs.microsoft.com/en-us/graph/api/group-post-owners?view=graph-rest-beta&tabs=javascript#example. However, it seems the API is made to support the adding of users but not applications as group owners. In fact, the error message I get is the following:
{'error': {'code': 'Request_BadRequest', 'message': "The reference target 'Application_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' of type 'Application' is invalid for the 'owners' reference.", 'innerError': {'date': '2021-11-30T10:07:24', 'request-id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'client-request-id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}}}
How can I solve this issue? I absolutely need the application to be a group owner in order to add the group to an access package catalog.
Thank you.
I tried in my environment .Please refer the request shown below to add application as owner to AAD Group as refered by @Ansuman.
But by using directoryObjects instead of users and by using Objectid of service principal of the application.
(You can get svp ObjectId by searching with the application id in enterprise applications.There the object Id is different from actual object id of application in appregistrations overview).
You may refer this Service Principal objects in Azure Active Directory
This is the Request:
POST https://graph.microsoft.com/beta/groups/<GroupObjectID>/owners/$ref
Content-type: application/json
{
"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/<ObjectIdOfServicePricipalOfApplication>"
}
Could see the owner of group named TESTsecuritygroup as web app :