MicrosoftTeamsPostMessage(ICakeContext, MicrosoftTeamsMessageCard, MicrosoftTeamsSettings) Method


Posts a message to a Microsoft Teams channel


public static HttpStatusCode MicrosoftTeamsPostMessage(this ICakeContext context, MicrosoftTeamsMessageCard message, MicrosoftTeamsSettings settings)


 var messageCard = new MicrosoftTeamsMessageCard {
    summary = "Cake posted message using Cake.MicrosoftTeams",
    title ="Cake Microsoft Teams",
    sections = new []{
        new MicrosoftTeamsMessageSection{
            activityTitle = "Cake posted message",
            activitySubtitle = "using Cake.MicrosoftTeams",
            activityText = "Here is the runtime Information",
            activityImage = "",
            facts = new [] {
                new MicrosoftTeamsMessageFacts { name ="CakeVersion", value = Context.Environment.Runtime.CakeVersion.ToString() },
                new MicrosoftTeamsMessageFacts { name ="TargetFramework", value = Context.Environment.Runtime.TargetFramework.ToString() },
                new MicrosoftTeamsMessageFacts { name ="IsCoreClr", value = Context.Environment.Runtime.IsCoreClr.ToString() }
    potentialAction = new [] { 
        new MicrosoftTeamsMessagePotentialAction {
            name = "View in Trello",
            target = new []{""}

    new MicrosoftTeamsSettings {
        IncomingWebhookUrl = EnvironmentVariable("MicrosoftTeamsWebHook")


Type Description


Name Type Description
context ICakeContext The context.
message MicrosoftTeamsMessageCard The message as MicrosoftTeamsMessageCard.
settings MicrosoftTeamsSettings The settings.

Return Value

Type Description
HttpStatusCode Response Code Description Details
200OkA well-formed request is sent to an existing webhook. The request contains a valid payload, and has a valid corresponding webhook configuration.
400Bad RequestAn incorrectly-formed request is sent to a webhook that exists. The payload could contain non-parseable JSON, incorrect JSON values (e.g.expected a String, got an array), incorrect content-type, etc..
404Not FoundA request is sent to a webhook that does not exist.
413Payload Too LargeA request is sent to a webhook that is too large in size for processing.
429Too Many RequestsClient is sending too many requests and Office 365 is throttling the requests to a webhook.