使用Graph beta版为企业应用程序创建新的角色分配

时间:2019-07-31 05:59:48

标签: azure azure-active-directory azure-ad-graph-api

我正在尝试使用Graph api beta版为企业应用程序创建角色分配。

我正在按照Microsoft文档进行相同操作

https://docs.microsoft.com/en-us/graph/api/serviceprincipal-post-approleassignments?view=graph-rest-beta&tabs=http

错误:

这是我在检查时遇到的错误:

  

仅在包含的实体上支持写入请求

我也使用Azure AD Graph(graph.windows.net)尝试了相同的操作,并且能够实现以下目标。

{
  "error": {
    "code": "BadRequest",
    "message": "Write requests are only supported on contained entities",
    "innerError": {
      "request-id": "f8b80735-c516-4a65-9f42-2b3088f2951a",
      "date": "2019-07-30T09:23:13"
    }
  }
}

1 个答案:

答案 0 :(得分:0)

我可以通过Microsoft Graph API重现您的问题,不确定是什么原因导致了问题。 ,它是Beta版本,我不建议您在生产环境中使用它。

Azure AD Graph API对我有用,您可以参考以下请求示例。

注意id是由目标资源应用程序resourceId在其appRoles属性中声明的角色ID。我的示例应用程序未声明任何权限,因此我指定了默认ID(零GUID 00000000-0000-0000-0000-000000000000)。

POST https://graph.windows.net/myorganization/servicePrincipals/<objetc id of the service principal>/appRoleAssignments?api-version=1.6 

{
    "id":"00000000-0000-0000-0000-000000000000",
    "principalId":"<object id of the user/group/service principal being granted the access>",
    "resourceId":"<objetc id of the service principal which the assignment was made>"

}

enter image description here