![](/img/trans.png)
[英]Accessing calendar via Microsoft Graph API while the user is not signed in
[英]Creating a user via Microsoft Graph API
我正在嘗試執行此 curl 請求
curl --location --request POST 'https://graph.microsoft.com/v1.0/users' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {BEARER_TOKEN}' \
--data-raw '{
"accountEnabled": true,
"displayName": "displayName-value",
"mailNickname": "mailNickname-value",
"userPrincipalName": "test666@mytennant.com",
"passwordProfile" : {
"forceChangePasswordNextSignIn": true,
"password": "password"
}
}'
我不斷得到
{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"date": "2020-10-23T14:01:06",
"request-id": "caf9e0be-88fc-4a4e-a6eb-fed1ccedb90c",
"client-request-id": "caf9e0be-88fc-4a4e-a6eb-fed1ccedb90c"
}
}
}
有人可以幫我弄清楚這里出了什么問題嗎?
根據您提供的錯誤,您似乎沒有創建用戶的正確權限。
在令牌中,您缺少權限,因此在發出圖形請求之前,您需要將令牌與
User.ReadWrite.All, Directory.ReadWrite.All.
我提出了以下請求,但沒有獲得所需的許可,然后我收到了與您在下面看到的相同的錯誤
后來我添加了權限並請求了新令牌,然后進行了圖形調用。 現在我成功地創建了用戶
卷曲
curl --location --request POST 'https://graph.microsoft.com/v1.0/users' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{ "accountEnabled": true, "displayName": "displayName-value", "mailNickname": "mailNickname-value", "userPrincipalName": "upn-value1@xx.live", "passwordProfile" : { "forceChangePasswordNextSignIn": true, "password": "xx@123" } }'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.