“The specified Teams flowbot adaptive card request is missing or invalid”

The Challenge

If you’ve been working with adaptive card tasks in Power Automate, such as “Post adaptive card in a chat or channel” or “Post adaptive card and wait for a response“, and have come across the above error, the below information will (hopefully) resolve your issue.

The Solution

The underlying problem is very likely due to dynamic text that you are injecting into the adaptive card that contains double quote (“) characters. When injecting this into the adaptive card schema, you need to do a simple replace to ensure your quotes are escaped, as such:

replace(variables('MyText'),'"','\"')

In the above example, you’d simply replace variables(‘MyText’) with your dynamic value, whether that be coming from SharePoint, etc…

However, it’s unfortunately not quite that simple, as I’ve seen double quotes get automatically escaped in some O365 environments, and I’ve seen it not get escaped in others!

The Fail-Safe Solution

To account for either scenario happening (Power Automate possibly escaping the double quotes for you or quite possibly not escaping them), we’re going to do 2 replaces to essentially ‘undo’ the escape if it’s already been done (and doing no harm if it wasn’t escaped since it won’t find any matches), and then do the final escape listed above, which ensures our double quotes are escaped, whether or not they already were escaped. This assures us that regardless of the specific behavior in your environment, it’s going to work, no matter what, and that’s the solution we’re always going for.

replace(replace(variables('MyText'),'\"','"'),'"','\"')

I hope this has helped you (and saved you time)!

Cheers,
Matt

Add a Comment

Your email address will not be published. Required fields are marked *