Microsoft Graph - AddOwner API 不允许我将应用程序添加为组所有者

Microsoft Graph - AddOwner API does not let me add an Application as group owner

我正在使用 Microsoft Graph API Beta 版将应用程序添加为组的所有者(我通过 Azure 控制台验证了这是可能的)。 我为我的案例找到的 API 是这个:https://docs.microsoft.com/en-us/graph/api/group-post-owners?view=graph-rest-beta&tabs=javascript#example。 但是,API 似乎是为了支持添加用户而不是应用程序作为组所有者。 事实上,我得到的错误信息如下:

{'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'}}}

我该如何解决这个问题? 我绝对需要应用程序成为组所有者才能将组添加到访问包目录。

谢谢。

我在我的环境中尝试过。请参考下面显示的请求,将应用程序作为所有者添加到 AAD 组,如@Ansuman 所引用。 但是通过使用 directoryObjects 而不是用户并使用应用程序的 Objectid of service principal

(您可以通过在企业中使用应用程序 ID 进行搜索来获取 svp ObjectId applications.There 对象 ID 与应用注册概述中应用程序的实际对象 ID 不同)。

你可以参考这个Service Principal objects in Azure Active Directory

这是请求:

POST https://graph.microsoft.com/beta/groups/<GroupObjectID>/owners/$ref
Content-type: application/json
{
    "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/<ObjectIdOfServicePricipalOfApplication>"
}

可以将名为 TESTsecuritygroup 的组的所有者视为 Web 应用程序: