Adaptive card not sending to user

Turns out the “BadRequest” error was actually all down to the data that was being passed into the AdaptiveCard.

string callCardJson = CreateJsonPayloadAsDataForAdapativeCard();
var myInfo = JsonConvert.DeserializeObject<JsonPayLoad>(callCardJson);
var templateJson = await WebhookController.GetCardText("my_template");
#if DEBUG
 templateJson = await WebhookController.GetCardText("my_template_test");
#endif
AdaptiveCardTemplate template = new AdaptiveCardTemplate(templateJson);
var myData = new
{
    title = myInfo.title,
    name = myInfo.name,
    token = myInfo.token,
    reference = myInfo.reference,
    info = my.info
};
string cardJson = template.Expand(myData);
AdaptiveCardParseResult result = AdaptiveCard.FromJson(cardJson);
card = result.Card;

So the AdaptiveCard was being used as a generic card in multiple scenarios but not all the data fields would be required in all the scenarios so initially I was passing blank values into the json data object for things such as token and reference above. When this was then deserialized above and then passed into the AdapativeCard, it caused the “BadRequest” error. I fixed the issue by removing the blank entries in the json data object!

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top