Sandeep Thomas
Sandeep Thomas

Reputation: 4759

Get user photo from graphapi and set it as profile picture in Angular application

I am trying to set profile picture using graph API. Here is the service

  readdetails():Observable<any>{   
    return this.http.get<any>('https://graph.microsoft.com/v1.0/me/photo');
  }

So I am getting the JSON without much issue and here is how it looks

{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('69sdf57b-f186-4007-b481-438fd5a870d3')/photo/$entity","@odata.mediaContentType":"image/jpeg","@odata.mediaEtag":"\"F52AEF83\"","id":"648X648","height":648,"width":648}

But I have no idea, how to use this information to set as src of my image in component

Upvotes: 1

Views: 818

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222712

If you look at the response, you need a base64 encoded representation of the image. You need to tell Angular to expect a Blob using the responseType parameter.

Check this answer for more details

Upvotes: 1

Related Questions