Handling Adaptive Cards Version Mismatch Issue
Introduction
Problem Statement
Solution
Summary
Introduction
Adaptive Cards is a way in which Developers can exchange data and content in a common way and the JSON payload used for creating the card can be used in any device or UI Framework. In addition to that there is no programming requirements for building these cards as the structure is completely defined by JSON(JavaScript Object Notation).In addition to it, we can style the card in a standard way so that it appears consistently across different platforms.
We can use the adaptive card designer to design the JSON for the adaptive card.
Problem Statement
However, while adding the generated JSON to the Power Automate Post adaptive card in chat or channel was throwing the error “We are sorry, this card couldn’t be displayed”
Solution
There can be multiple reasons for this especially if the JSON is not formatted correctly as per syntax. But one of the possible causes if we are copy pasting the developed JSON from Adaptive card designer is that, it targets version 1.5 by default. Taking a look at the official documentation, the supported versions in Microsoft Teams are 1.4 for Bot card cards and 1.3 for User sent cards. This holds true as of Jan 2022 and may change in the subsequent months as new updates are rolled out to Teams Platform
We can either change the target version in the adaptive card designer while working on the JSON as below:
Or we can easily change it directly in the JSON schema by updating the version number to 1.4 or less:
This will fix the issue with the rendering of the adaptive card.
Note: Since we are working on a Bot Sent Card, we have downgraded to v1.4, in case you are working on a User sent card, ensure to downgrade to v1.3. This downgrade holds good as of Jan 2022 and in the future when updates are rolled out to Teams, higher schema versions would be supported.
Summary
Thus we saw a potential issue that would cause problems with the rendering of the adaptive cards in Teams due to mismatch in supporter version number and the ways to solve it.