如何通过 Microsoft Graph API 将成员添加到组?
根据将成员添加到特定组的文档,它需要以下调用:
POST https://graph.microsoft.com/v1.0/groups/{id}/members/$ref
Content-type: application/json
Content-length: 30
{
"@odata.id": "https://graph.microsoft.com/v1.0/users/{id}"
}
我的问题在于这个 API:
https://graph.microsoft.com/v1.0/groups/{id}/members/$ref
{id}
=> 组id,members
=> 向群组添加成员
现在要添加或发布的用户/成员数据/参数在哪里?
是 "@odata.id": "https://graph.microsoft.com/v1.0/users/{id}"
吗?
将成员添加到组时,我是否将 @odata.id
值作为成员/用户参数发布?
最佳答案
没错。您在技术上传递的是 ODATA 引用 ( ref$
) 到 user
Active Directory 中的对象,而不仅仅是 id
.
为了说明,让我们用这个虚构的 user
:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
"businessPhones": [
"+1 412 555 0109"
],
"displayName": "Megan Bowen",
"givenName": "Megan",
"jobTitle": "Auditor",
"mail": "MeganB@M365x214355.onmicrosoft.com",
"mobilePhone": null,
"officeLocation": "12/1110",
"preferredLanguage": "en-US",
"surname": "Bowen",
"userPrincipalName": "MeganB@M365x214355.onmicrosoft.com"
}
如果我们想将 Megan 添加到具有 id
的组中的 02bd9fd6-8f93-4758-87c3-1fb73740a315
调用看起来像这样:
POST https://graph.microsoft.com/v1.0/groups/02bd9fd6-8f93-4758-87c3-1fb73740a315/members/$ref
Content-type: application/json
{
"@odata.id": "https://graph.microsoft.com/v1.0/users/MeganB@M365x214355.onmicrosoft.com"
}
关于azure-active-directory - 如何使用 Microsoft Graph API 将成员添加到组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47653515/