Home

How to get user photo in Nodejs using Graph API?

Rohit Jadhav
Regular Visitor

I am using following API to get users profile picture 
profilephoto_get

After looking at response I see something like follows 

����JFIF``��C  $.' ",#(7),01444'9=82<.342��C

2!!2222222222222222222222222222222222222222222222
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������
���w!1AQaq"2�B���� #3R�br� 

now I am trying to use Data URI format to display this image in adaptive cards. So I am using following code to convert that to base45

Type 1: let base64Img = Buffer.from('above-data').toString('base64')

Type 2: let base64Image = new Buffer('above-data', 'binary').toString('base64');

Type 3: Using NPM Btoa module

var b64 = btoa('above-data');

 

None of ways I tried are working. As in if I put output in correct URI scheme to online converter it doesn't parse back to the image.

Please suggest where I might be going wrong ? Is there any chance I am not consuming API response correctly ?





 

Related Conversations
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
2 Replies
*Updated 9/3* Syncing in Microsoft Edge Preview Channels
Elliot Kirk in Articles on
205 Replies
Early preview of Microsoft Edge group policies
Sean Lyndersay in Discussions on
65 Replies