![](/img/trans.png)
[英]Allow all domains when adding a new user to Azure B2C using the microsoft Graph API
[英]Adding User to Group using Graph API B2C
我使用Azure AD B2C來創建用戶。 創建用戶后,我想將它們添加到組中
使用Postman我發出了以下請求(標題中包含訪問令牌)。 注意:我已成功使用Api創建了一個組。
POST https://graph.windows.net/{azure-tenant}/groups/{group-objectId/members/$ref?api-version=1.6
身體:
{
"@odata.id": "https://graph.windows.net/{azure-tenant}/directoryObjects/{user-objectId}"
}
這是文檔指定的內容。 無論發送的正文,我都會收到以下錯誤
{
"odata.error": {
"code": "Request_BadRequest",
"message": {
"lang": "en",
"value": "The request URI is not valid. Since the segment 'members' refers to a collection, this must be the last segment in the request URI. All intermediate segments must refer to a single resource."
},
"requestId": "48cf65f3-20ba-411e-8121-f7ea54252f3a",
"date": "2019-05-27T06:09:25"
}
}
我試過刪除/ $ ref
POST https://graph.windows.net/{azure-tenant}/groups/{group-objectId/members?api-version=1.6
身體:
{
"@odata.id": "https://graph.windows.net/{azure-tenant}/directoryObjects/{user-objectId}"
}
以及
{
"@odata.id": "https://graph.windows.net/{azure-tenant}/users/{user-objectId}"
}
現在返回的錯誤是:
{
"odata.error": {
"code": "Request_BadRequest",
"message": {
"lang": "en",
"value": "Unsupported resource type 'DirectoryObject' for operation 'Create'."
},
"requestId": "2c36cc6d-383c-44f8-8609-2ac3e3efc862",
"date": "2019-05-27T06:15:26"
}
}
我一直在使用的文檔https://docs.microsoft.com/en-us/graph/api/group-post-members?view=graph-rest-1.0&tabs=javascript
您正在使用graph.windows.net端點,因此您應該參考azure ad graph api 。
POST https://graph.windows.net/myorganization/groups/b4bda672-1fba-4711-8fb1-5383c40b2c14/$links/members?api-version=1.6
{
"url": "https://graph.windows.net/myorganization/directoryObjects/3eb6055a-baeb-44d4-a1ea-2fee86d8891b"
}
您提到的文檔是microsoft graph api。 端點應為https:// graph.microsoft.com 。
您可以使用Microsoft Graph explorer來調用這些api。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.