Search code examples
jsonbase64microsoft-teamswebhooks

Webhook Messagecard Connector Posts Distorting Image


I am trying to send a message to a teams channel using a webhook. I need this to include an image. The message sends successfully using activityImage, however the image gets rounded every time/is distorted. I would like it to just post the image in the dimensions it exists ideally (all are small images).

It doesn't seem like it's an issue with the base64 encoding so I'm guessing there's a syntax issue. I have not been able to find a thread where anyone else is having this problem where their images are rounded. I've tried using messagecard params image, images, and heroImage but none of these will even post the image to teams successfully.

The Messagecard: {"@type":"MessageCard","@context":"https://schema.org/extensions","summary":"summary","themeColor":"2e8b57","title":"Daily Scrum","sections":[{"activityImage": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAVSURBVBhXY3hvaf9WRYcBiN/KqAAAJ40FDwasafMAAAAASUVORK5CYII="}]}

Note: encoding is done using https://www.base64-image.de/


Solution

  • For anyone running into a similar issue where you're unable to get messagecards posting your image in its proper resolution - I found that the text attribute can accomplish this. Using image or an array of images distorted the image resolution, and ActivityImage made the image round which was undesired. Using Base64 threw 500 errors depending on the size of the image. Below is what worked for me.

    {
    "@type": "MessageCard",
    "@context": "https://schema.org/extensions",
    "summary": "summary",
    "themeColor": "2e8b57",
    "title": "Daily Scrum 11/6/2022",
    "text": "![](https://somewebsite.com/the_image.jpg)"
     }