Office365 API - Pulling my userphoto

微笑、不失礼 提交于 2019-12-06 11:54:51
Ampers

This is really ElioStruyf's answer.

The endpoint is now called "photo" and not "userphoto"

To get the photo information you use:

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

To get the photo you call

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

To get list of all available photo sizes, use this API endpoint -

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

Sample response -

{
    "@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
        }
    ]
}

To fetch actual blob of desired photo size, call this API -

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

Nothing's wrong with your organization's office 365 configuration. Outlook UserPhoto API has stopped working with the given endpoint. Unfortunately, they haven't updated the documentation yet. Let's hope it will be up soon or they will at least update documentation with new API endpoint.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!