简体   繁体   中英

Getting Office 365 Outlook User Photo through REST

I'm currently able to view the photo metadata using :

GET https://outlook.office.com/api/v2.0/me/photo

and i'm able to get a correct response like this :

{
"@odata.context": "https://outlook.office.com/api/v2.0/$metadata#Me/photo/$entity",
"@odata.id": "https://outlook.office.com/api/v2.0/Users('ddfcd489-628b-7d04-b48b-20075df800e5@1717622f-1d94-c0d4-9d74-f907ad6677b4')/photo",
"@odata.mediaContentType": "image/jpeg",
"@odata.mediaEtag": "\"BA09D118\"",
"Id": "240X240",
"Width": 240,
"Height": 240
}

However I get NULL when I try to query :

GET https://outlook.office.com/api/v2.0/me/photo/$value

What might be the reason?

I do not know the reason why it does not work with the alias "me" but if you use the @odata.id and request the value with the following request

https://outlook.office.com/api/v2.0/Users('ddfcd489-628b-7d04-b48b-20075df800e5@1717622f-1d94-c0d4-9d74-f907ad6677b4')/photo/$value

it works.

Fixed it.. I just had to include the content type in the header as:

"Content-Type: image/jpg"

It works for both 'me' and 'odata id'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM