Office 365 profile avatar picture

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Office 365 profile avatar picture

Message par ForumBot »

Office 365 profile avatar picture
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Office 365 profile avatar picture

Message par ForumBot »

You can also use the Office365 Unified API (Preview) [https://msdn.microsoft.com/office/office365/APi/photo-rest-operations](https://msdn.microsoft.com/office/office365/APi/photo-rest-operations)

And use as Base64 Encoded Image. Please pay attention on the changed API since the last Update.

Here my code:

```
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get,
"https://outlook.office.com/api/beta/me/photos('96x96')/$value");
request.Headers.Add("ACCEPT", "image/*");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
HttpResponseMessage response = await client.SendAsync(request);
byte[] byteArray = await response.Content.ReadAsByteArrayAsync();

string base64ImageRepresentation = Convert.ToBase64String(byteArray);

if (!response.IsSuccessStatusCode && response.StatusCode >= HttpStatusCode.BadRequest)
{
return string.Empty;
}

return base64ImageRepresentation;

```
Répondre

Revenir à « Excel & VBA »