How to send a hyperlink in a incoming-webhook message?

Viewed 2503

I know I can use html and markdown in my incoming webhook, but when I try to embed a link, it does not work. Need help, please

curl -H "Content-Type: application/json" -d "{\"text\": \"<a href=' www.microsoft.com'>visit</a >\"}" <my webhook url> curl -H "Content-Type: application/json" -d "{\"text\": \"[visit](www.microsoft.com)\"}" <my webhook url>

2 Answers

Standard markdown can be used:

curl --header "Content-Type: application/json" \  
     --data "{\"text\": \"[visit](https://www.microsoft.com)\"}" \  
     <my webhook url>  

Note that OP omitted the URI scheme, which prevents Teams from identifying the URL as a valid one.

I got the similar issue before, and I found I could use adaptive cards. It's much more powerful! Below is the sample payload.

{
    "@type": "MessageCard",
    "@context": "http://schema.org/extensions",
    "themeColor": "0076D7",
    "summary": "a summary",
    "sections": [{
        "activityTitle": "A title",
        "activitySubtitle": "a subtitle",
        "markdown": true
    }],
    "potentialAction": [{
        "@type": "ActionCard",
        "name": "Visit",
        "actions": [{
            "@type": "OpenUri",
            "name": "Visit",
                "targets": [
                    { "os": "default", "uri": "https://www.microsoft.com" }
                ]
        }]
    }]
}
Related