I would like to use user's profile image from MS graph in adaptive card. I have determined the API call I need to make is as follows
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/profilephoto_get
In this case I would be getting image as a binary data for a profile photo, that needs to converted into a base-64 string.
But, based on adaptive cards schema document looks like we should use URL property where value should be direct URL to the image
'url string Yes The URL to the image'
How should I approach this ? If there any way to use an IMAGE in Adaptive Card w/o direct URL to the image ??
You can use a data URI to encode the bytes directly into the payload. Something like this sample:
var photo = await client.Me.Photos[size].Content.Request().GetAsync();
var photoStream = new MemoryStream();
photo.CopyTo(photoStream);
var photoBytes = photoStream.ToArray();
return string.Format("data:image/png;base64,{0}",
Convert.ToBase64String(photoBytes));