Office365 API - 提取我的用户照片

Office365 API - Pulling my userphoto

我有一个简单的网络应用程序,在过去一个月左右的时间里,它运行正常:

outlook.office365.com/api/beta/Me/userphotos('120x120')/$value

但现在 returns:

{"error":{"code":"RequestBrokerOld-ParseUri","message":"Resource not found for the segment 'userphotos'."}}

如果我尝试以下任一操作,我会得到同样的错误:

https://outlook.office365.com/api/beta/Me/userphoto
https://outlook.office365.com/api/beta/Me/userphotos
https://outlook.office365.com/api/beta/Me/userphoto/$value

有没有可能是我的组织改变了某些东西导致了这个?还是此请求的工作方式发生了总体变化?

在同一个应用程序中,我的其他电子邮件和日历请求都工作正常,这只是一个表面问题,没有在顶角显示用户个人资料图片。

贵组织的 Office 365 配置没有问题。 Outlook UserPhoto API 已停止使用给定端点。不幸的是,他们还没有更新文档。我们希望它能尽快完成,或者他们至少会使用新的 API 端点更新文档。

这真的是ElioStruyf的回答。

端点现在称为 "photo" 而不是 "userphoto"

获取您使用的照片信息:

https://outlook.office365.com/api/beta/Me/photo

获取你调用的照片

https://outlook.office365.com/api/beta/Me/photo/$value

要获取所有可用照片尺寸的列表,请使用此 API 端点 -

https://outlook.office.com/api/beta/me/Photos/

示例响应 -

{
    "@odata.context": "https://outlook.office.com/api/beta/$metadata#Me/Photos",
    "value": [
        {
            "@odata.id": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('48X48')",
            "@odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('48X48')",
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "\"7A1F3A9D\"",
            "Id": "48X48",
            "Height": 48,
            "Width": 48
        },
        {
            "@odata.id": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('64X64')",
            "@odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('64X64')",
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "\"7A1F3A9D\"",
            "Id": "64X64",
            "Height": 64,
            "Width": 64
        },
        {
            "@odata.id": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('96X96')",
            "@odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('96X96')",
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "\"7A1F3A9D\"",
            "Id": "96X96",
            "Height": 96,
            "Width": 96
        },
        {
            "@odata.id": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('120X120')",
            "@odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('120X120')",
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "\"7A1F3A9D\"",
            "Id": "120X120",
            "Height": 120,
            "Width": 120
        },
        {
            "@odata.id": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('240X240')",
            "@odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('240X240')",
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "\"7A1F3A9D\"",
            "Id": "240X240",
            "Height": 240,
            "Width": 240
        },
        {
            "@odata.id": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('360X360')",
            "@odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('360X360')",
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "\"7A1F3A9D\"",
            "Id": "360X360",
            "Height": 360,
            "Width": 360
        },
        {
            "@odata.id": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('432X432')",
            "@odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('432X432')",
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "\"7A1F3A9D\"",
            "Id": "432X432",
            "Height": 432,
            "Width": 432
        },
        {
            "@odata.id": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('504X504')",
            "@odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('504X504')",
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "\"7A1F3A9D\"",
            "Id": "504X504",
            "Height": 504,
            "Width": 504
        },
        {
            "@odata.id": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('648X648')",
            "@odata.readLink": "https://outlook.office.com/api/beta/Users('John.Doe@contoso.com')/Photos('648X648')",
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "\"7A1F3A9D\"",
            "Id": "648X648",
            "Height": 648,
            "Width": 648
        }
    ]
}

要获取所需照片大小的实际 blob,请调用此 API -

https://outlook.office.com/api/beta/me/Photos('120X120')/$value