Microsoft Graph API x C# - 获取具有定义大小的个人资料图片

Microsoft Graph API x C# - Get profile picture with defined size

我想检索我的 Azure Active Directory 中的所有用户及其个人资料照片。

我的请求是这样的:

var photo = await _graphServiceClient.Users[userId].Photo.Content.Request().GetAsync()

我知道理论上可以定义所需的尺寸:

现在我想知道如何在 C# 中做到这一点。我知道它实际上对组是这样工作的:

var photo = await _graphServiceClient.Groups[groupId].Photos["64x64"].Content.Request().GetAsync()

如果我在用户请求中使用括号,它会显示“无法应用索引...”。

var photo = await _graphServiceClient.Users[userId].Photo["64x64"].Content.Request().GetAsync()

希望有人能帮忙:)

可能您需要 Photos 而不是 Photo

var photo = await _graphServiceClient.Users[userId].Photos["64x64"].Content.Request().GetAsync()