Apologies for the novice question. I have been experimenting with posting alerts from a Python script (using the pymsteams library) to one of our internal Teams channels via an old-school Office 365 Connectors webhook. Today, alongside a posted alert, I got the notice that those connectors are being deprecated:
Per the advice in that article, I am trying to transition to a Power Automate based flow. I was able to set up the linked template with our team and channel IDs, and I got a URL which I presume is the new webhook URL. When I tried to post to that webhook, I got an error; within the web interface I can see that the flow failed on the "Send each adaptive card" step:
The execution of template action 'Send_each_adaptive_card' failed: the result of the evaluation of 'foreach' expression '@triggerOutputs()?['body']?['attachments']' is of type 'Null'. The result must be a valid array.
It seems like the content that I am trying to send is not being seen as an attachment? I don't have a ton of insight into how the request is actually formed, since I am using the library to make the request. The code within Python that I'm using to send the message is as follows:
import pymsteams
import os
def post_teams(message):
myTeamsMessage = pymsteams.connectorcard(os.environ.get("TEAMS_WEBHOOK_URL"))
myTeamsMessage.text(message)
myTeamsMessage.send()
(The message is a string with markdown content; I swapped the URL from the Power Automate flow in to my webhook environment variable there.)
Do I need to format my request to the webhook URL differently (perhaps using the requests library or similar), or is the issue on the Power Automate side - should I be telling it to get the content in some other way? From their repo, I see that pymsteams has not been updated in quite some time, so possibly it does not post requests in the format that Power Automate expects.
Thank you in advance for any insight you can provide!


Report
All responses (
Answers (