Forum Discussion
Christopher_Lutz
Oct 06, 2023Copper Contributor
Teams update breaks cards
After upgrading to the newest version of Microsoft Teams for desktop we are receiving an unusual error in the new teams client. On the newest version of the teams client we are getting the follow...
- Oct 09, 2023Meghana-MSFT
I think I might have found what may have happened. If I remove the following line from C# code it renders correctly in both the old version and the new version.
Type = "message",
Christopher_Lutz
Oct 09, 2023Copper Contributor
Some more information.
This is the C# function that I am using to post the message to the web hook end point
/// <summary>
/// Send a message to teams group
/// </summary>
/// <param name="heading">Message Heading</param>
/// <param name="message">Message to send</param>
/// <param name="endpoint">End point URL</param>
public async static Task<bool> SendMessage(string endpoint, string message, string heading)
{
ContentAttributes content = new()
{
Type = "message",
Title = heading,
Text = message?.Replace("\r\n", "\n", OrdinalIgnoreCase) ?? string.Empty,
};
string contentJson = JsonConvert.SerializeObject(content);
using StringContent messageCard = new(contentJson);
using HttpClient Client = new();
HttpResponseMessage httpResponseMessage = await Client.PostAsync(new Uri(endpoint), messageCard).ConfigureAwait(false);
string response = await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
if (response == "1")
{
return true;
}
return false;
}
This is the C# function that I am using to post the message to the web hook end point
/// <summary>
/// Send a message to teams group
/// </summary>
/// <param name="heading">Message Heading</param>
/// <param name="message">Message to send</param>
/// <param name="endpoint">End point URL</param>
public async static Task<bool> SendMessage(string endpoint, string message, string heading)
{
ContentAttributes content = new()
{
Type = "message",
Title = heading,
Text = message?.Replace("\r\n", "\n", OrdinalIgnoreCase) ?? string.Empty,
};
string contentJson = JsonConvert.SerializeObject(content);
using StringContent messageCard = new(contentJson);
using HttpClient Client = new();
HttpResponseMessage httpResponseMessage = await Client.PostAsync(new Uri(endpoint), messageCard).ConfigureAwait(false);
string response = await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
if (response == "1")
{
return true;
}
return false;
}