With the below code i am getting StatusCode: 400, ReasonPhrase: 'Bad Request' but no further info:
response = {StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Cache-Control: no-cache
Pragma: no-cache
Server: Microsoft-IIS/10.0
request-id: 5a296706-4079-47ed-aa57-e50eb3dd78fb...
}
I have already setup the webhook in Teams, appreciate pointer in the right direction.
var card = new AdaptiveCard(new AdaptiveSchemaVersion(1,0));
var columnSet = new AdaptiveColumnSet();
var column = new AdaptiveColumn();
var text = new AdaptiveTextBlock("one");
column.Items.Add(text);
columnSet.Columns.Add(column);
card.Body.Add(columnSet);
try
{
var httpContent = new StringContent(card.ToJson(), Encoding.UTF8, AdaptiveCard.ContentType);
var response = await httpClient
.PostAsync(settings.TeamsWebhook,httpContent)
.ConfigureAwait(false);
if (response.StatusCode == HttpStatusCode.OK)
{
// Do something with response. Example get content:
// var responseContent = await response.Content.ReadAsStringAsync ().ConfigureAwait (false);
}
}
The produced JSON is as follows:
{
"type": "AdaptiveCard",
"version": "1.0",
"title": "test",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "one"
}
]
}
]
}
]
}
I have also tried by adding a container type (as i cannot find the attatchment element as below) and get the same errror.
var card = new AdaptiveCard(new AdaptiveSchemaVersion(1,2));
var columnSet = new AdaptiveColumnSet();
var column = new AdaptiveColumn();
var text = new AdaptiveTextBlock("one");
var container = new AdaptiveContainer();
column.Items.Add(text);
columnSet.Columns.Add(column);
container.Items.Add(columnSet);
card.Body.Add(container);
Gives the following json:
{
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "one"
}
]
}
]
}
]
}
]
}