0

I have sent a request to Microsoft Graph, to get the photo from the user. It looks like this --GET https://graph.microsoft.com/v1.0/users/USER_ID/photo/$value I get, as a response, binary format of an image, and as doc suggests I made blob object, like this. Type od data(from image) that I recieve, I set to be ng.HttpPromise.

I get url, that I set for image src (in html), but photo isn't showing, and I don't have any Error popped up.

  • Could you please wrap your GET request example into backticks '`' ? – Grwlf Mar 27 '20 at 16:23
  • @MinaRacic, posting screenshots of code is discouraged, could you please include a code sample into a post and update a question in this regard? – Vadim Gremyachev Mar 28 '20 at 19:09
  • @MinaRacic, .. and maybe provide some details, for instance, what is the type of `data` object, `ArrayBuffer`? regarding _photo isn't showing_ how the image is getting rendered from `contact.photoUrl` – Vadim Gremyachev Mar 28 '20 at 19:16
  • 1
    @VadimGremyachev I tried to explain it in more details. Please let me know if everything is clear now. – Mina Racic Mar 30 '20 at 08:20

1 Answers1

0

To get a user's photo using Graph, use: https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/photo/$value. From the sample shared(see below) I can see a minor mistake: Sample Code

Once the response completes, you need to call data.blob() which returns a promise containing the blob, which you can then pass to createObjectUrl after resolution.

this.videoEventServie.getPersonPhoto(contact).then(data => {
  return data.blob();

}).then(function(currentBlob){
  var src= URL.createObjectURL(currentBlob);
  myImage.photoUrl = src;
});

Please see this answer: Using JavaScript to display a Blob for additional context.

Diana
  • 690
  • 6
  • 14