【发布时间】:2024-05-04 14:50:02
【问题描述】:
我正在查询用户的照片元数据,然后使用元数据中的 ID 来查询实际照片:
https://graph.microsoft.com/v1.0/users/<user id>/photo 返回
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('<user id>')/photo/$entity",
"@odata.mediaContentType": "image/jpeg",
"@odata.mediaEtag": "W/\"...\"",
"id": "default",
"height": 64,
"width": 64
}
请注意,它的 ID 是 default。然后,当我尝试使用 https://graph.microsoft.com/v1.0/users/<user id>/photos/default/$value 获取内容时,图形返回 HTTP 400 和
{
"error": {
"code": "ErrorInvalidImageId",
"message": "The image ID is not valid",
"innerError": {
"date": "2021-12-02T14:59:49",
"request-id": "...",
"client-request-id": "..."
}
}
}
如果我将上述 URL 中的 default 替换为 64x64(元数据中的照片尺寸),一切都很好,即 https://graph.microsoft.com/v1.0/users/<user id>/photos/64x64/$value 返回照片。
对于许多用户来说,从https://graph.microsoft.com/v1.0/users/<user id>/photo 返回的 ID 看起来像 64x64,而且这种 ID 总是有效的。
为什么 Graph 会为某些用户返回 default,我应该如何处理?每当我收到default 时,从宽度和高度创建 ID 是否安全?
【问题讨论】:
标签: azure-active-directory microsoft-graph-api