I am trying to send a base64-string which is a png to our Teams-channel which have an "Incoming Webhook" setup.
The message is sent to the channel but no image is displayed and when I searched for this it seems that I can't send an image or any other type of attachment as a base64-string to Teams?
Extremely new to json and consuming / using rest api in general.
I have no idea how to instruct the body that the string is a base64-string and the expected output should be a png-file.
Tried this:
$webhook = 'URLtoTeamsWebhook'
$base64 = "longBase64string"
$Body = @{
"text" = "Hello World! from PowerShell"
"imageData" = "$base64"
}
$params = @{
Headers = @{'accept'='application/json'}
Body = $Body | convertto-json
Method = 'Post'
URI = $webhook
}
Invoke-RestMethod @params
But it didn't work, also tried the code below with changes to the body:
$Body = @{
"type" = "string",
"contentEncoding" = "$base64",
"contentMediaType" = "image/png"
}
and it also didn't work.
"Didn't work" = Posting to Teams but not displaying the image at all.
Update:
Was able to figure this out, sort-of but would still appreciate a reply;
https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/cards/cards-reference
I guess you can "only" use their cards to send in data through their "Incoming webhook" and the card I would like to use is the "Hero Card" since the data is an alarm with a image of a graph, HOWEVER it is not supported when using a "connector" :(
I found this website;
https://github.com/grafana/grafana/issues/13121
and I've used the example there however that require me to have to send the picture (which is in a base64-format) to S3 in order for users to be able to view a larger picture.