I have a webhook setup to post a message to one of our Teams Team channels. I'm using one of the teams webhook examples given here: https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference#hero-card .
The problem I have is that I am unable to display multiple lines. In the example below, I'd like to separate out 'Test1' and 'Test2' on separate lines. However, using \n or \n in the JSON didn't translate to multi line format in Teams. Screenshot outcome attached below.
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"title": "Alerts",
"text": "*Test1 \n *Test\n",
"buttons": [
{
"type": "openUrl",
"title": "Open in SumoLogic",
"value": ""
}
]
}
}
]
}
What is the way to send a multi-line message to Teams using webhook? Any guidance here is appreciated.

Please try using \n\n and check.
This worked in a bash script.
# Replace newline with <br>
MULTILINE_STRING_BR=$(echo "$MULTILINE_STRING" | sed 's/$/<br>/g')
cat <<EOF >/tmp/msg.txt
{
"text": "Some introductory text:<br>
${MULTILINE_STRING_BR}"
}
EOF
# Send to teams channel
curl --request POST \
--silent \
--header "Content-Type: application/json" \
--data @/tmp/msg.txt \
"${TEAMS_WEBHOOK}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With