In a forge app I am developing, I send a Webhook POST Request to a Teams channel (see code below). When I am running locally with forge tunnel
, Teams responds with status 202 (success) and the message is successfully posted to the channel.
When I deploy with forge deploy
and then test, Teams receives the request and responds with 202, however the Workflow errors with:
ExpressionEvaluationFailed. 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.
I suspect that something is being changed in the request formatting itself.
Code that sends the Webhook request:
const payload = {
type: "message",
attachments: [
{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
$schema: "http://adaptivecards.io/schemas/adaptive-card.json",
type: "AdaptiveCard",
version: "1.2",
body: [
{
type: "Container",
items: [
{
type: "TextBlock",
text: message,
wrap: true
}
],
width: "stretch"
}
],
actions: [
{
type: "Action.OpenUrl",
title: "View PR",
url: pr.links.html.href || "https://bitbucket.org" // fallback
}
]
}
}
]
};
debugLog("Payload to Teams:", JSON.stringify(payload, null, 2));
// Step 3: Send message to Teams
try {
const response = await api.fetch(TEAMS_WEBHOOK_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
as: 'json'
});
debugLog("Teams alert sent. Status:", response.status);
} catch (error) {
debugLog("Error sending Teams alert:", error);
}
// Step 4: Return result to Forge
return {
success: overrideAllowed,
message: overrideMessage
};
}