我有B2C本地账号,当我尝试使用应用程序发布令牌的Graph API获取/更新他们的个人资料信息时,它工作了。但当我尝试获取/更新他们的头像时,我得到了404个错误。
请求:(GET)
https://graph.microsoft.com/v1.0/users/{userOid}/photo
回复: 404
{
"error": {
"code": "ImageNotFound",
"message": "Exception of type 'Microsoft.Fast.Profile.Core.Exception.ImageNotFoundException' was thrown.",
"innerError": {
"date": "2021-10-26T16:12:52",
"request-id": "ac24acee-8317-4d77-95ea-c69df189e7cb",
"client-request-id": "ac24acee-8317-4d77-95ea-c69df189e7cb"
}
}
}request:(PUT/POST),同时设置内容类型
https://graph.microsoft.com/v1.0/users/{userOid}/photo/$value
回复: 404
{
"error": {
"code": "UnknownError",
"message": "{\r\n \"errorCode\": \"ErrorUserResolutionFailedUserDoesNotExist\",\r\n \"message\": \"Exception of type 'Microsoft.Fast.Profile.Core.Exception.ProfileNotFoundException' was thrown.\",\r\n \"target\": null,\r\n \"details\": null,\r\n \"innerError\": null,\r\n \"instanceAnnotations\": []\r\n}",
"innerError": {
"date": "2021-10-26T16:13:55",
"request-id": "3517b374-a08d-41a1-8f68-9c9da3cbfb3b",
"client-request-id": "3517b374-a08d-41a1-8f68-9c9da3cbfb3b"
}
}
}发布于 2021-10-27 06:38:35
目前,您正在使用Microsoft Graph REST APIV1.0来获取/更新B2C本地帐户的用户照片。
,但1.0版中的这些操作仅支持用户的工作或学校邮箱,而不支持个人邮箱
因此,您可以使用Microsoft Graph REST API beta版本来获取/更新B2C本地帐户的用户照片。
使用测试版获取/更新用户照片时,此操作首先尝试在Microsoft 365中获取/更新照片。如果失败(由于用户没有邮箱),此API将尝试获取/更新Azure Active Directory中的照片
注意:如果要更新用户的头像,请仅使用PUT操作。
为了获取用户的头像,请确保用户在Azure AD中有头像。否则,它将抛出ImageNotFound错误。
Reference:
profilePhoto resource type - Microsoft Graph beta | Microsoft Docs
profilePhoto resource type - Microsoft Graph v1.0 | Microsoft Docs
https://stackoverflow.com/questions/69726744
复制相似问题