Azure active directory 如何使用Microsoft Graph API向组中添加成员

Azure active directory 如何使用Microsoft Graph API向组中添加成员,azure-active-directory,microsoft-graph-api,Azure Active Directory,Microsoft Graph Api,如何通过Microsoft Graph API向组中添加成员 根据向特定组添加成员的文档,它需要以下调用: POSThttps://graph.microsoft.com/v1.0/groups/{id}/members/$ref 内容类型:application/json 内容长度:30 { “@odata.id”:”https://graph.microsoft.com/v1.0/users/{id}” } 我的问题在于这个API: https://graph.microsoft.com/

如何通过Microsoft Graph API向组中添加成员

根据向特定组添加成员的文档,它需要以下调用:

POSThttps://graph.microsoft.com/v1.0/groups/{id}/members/$ref
内容类型:application/json
内容长度:30
{
“@odata.id”:”https://graph.microsoft.com/v1.0/users/{id}”
}
我的问题在于这个API:

https://graph.microsoft.com/v1.0/groups/{id}/members/$ref
  • {id}
    =>组id

  • 成员
    =>向组中添加成员

现在,要添加或发布的用户/成员数据/参数在哪里

是不是
“@odata.id”:https://graph.microsoft.com/v1.0/users/{id}“


在向组中添加成员时,是否将
@odata.id
值作为成员/用户参数发布?

这是正确的。从技术上讲,您传递的是一个ODATA引用(
ref$
)到Active Directory中的
user
对象,而不仅仅是一个
id

为了说明,让我们以这个虚构的
用户

{
“@odata.context”:”https://graph.microsoft.com/v1.0/$metadata#users/$entity“,
“id”:“48d31887-5fad-4d73-a9f5-3c356e68a038”,
“商务电话”:[
"+1 412 555 0109"
],
“displayName”:“Megan Bowen”,
“givenName”:“Megan”,
“职务名称”:“审计师”,
“邮件”:MeganB@M365x214355.onmicrosoft.com",
“手机”:空,
“办公地点”:“1110年12月”,
“首选语言”:“en US”,
“姓”:“伯恩”,
“userPrincipalName”:MeganB@M365x214355.onmicrosoft.com"
}
如果我们想将Megan添加到id为02bd9fd6-8f93-4758-87c3-1fb73740a315的a组中,调用如下所示:

POSThttps://graph.microsoft.com/v1.0/groups/02bd9fd6-8f93-4758-87c3-1fb73740a315/members/$ref
内容类型:application/json
{
“@odata.id”:”https://graph.microsoft.com/v1.0/users/MeganB@M365x214355.onmicrosoft.com“
}

传递用户Id时,它也在工作:

POST url: https://graph.microsoft.com/v1.0/groups/{group_id}/members/$ref
Content-type: application/json

Content string: {"@odata.id": "https://graph.microsoft.com/v1.0/users/{user_id}"}
组id-组对象id

用户id-用户对象id