I am trying to send a failure message to teams via incoming webhook. So whenever the flow will fail due to any reason, a variable called jv_error_message should be shown as output in the relevant teams channel. The problem is that the variable is not appearing. If I put any text, that appears in the team but not the underlying value of variable.
This is my payload template in JSON format:
{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"themeColor": "64a837",
"title": "Error Occurred",
"text": "jv_error_message: {{jv_error_message}}"
}
Below are webhook properties:
I have added variable as well in Export tab
This is the output I am getting:
I have tried putting dollar signs in the JSON as well as the payload variable section in webhook properties but unfortunately, nothing is working for me.
Thanks
In your payload, the variable will definitely need to be in the standard ${variable_name} format, and might need to be between single quotes. Here's an example payload:
{
"text": "Failure: '${job_name}' \nLine2"
}
Could you try something. Take your existing JSON, and use it directly in the component.
Payload Template: [Custom]
Payload: <your JSON>
IIRC the variable handling is not consitent within this feature. As Phil already mentioned, there might be a difference if you save the JSON template beforehand vs. entering the JSON directly in "custom" mode.
In our environment, we sometimes have to use the "{{" syntax from your example and sometimes something like:
"name": "Detailed Error",
"value": "${detailed_error}"
This is our complete JSON template for the general "Mange Error Reporting" feature:
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "Failed Matillion Job in Project ${project_name}",
"sections": [{
"activityTitle": "Failed Matillion Job in Project ${project_name}",
"activitySubtitle": "Job Name: ${job_name}",
"activityImage": "https://upload.wikimedia.org/wikipedia/commons/thumb/6/63/Green_bug.svg/200px-Green_bug.svg.png",
"facts": [{
"name": "Component Name",
"value": "${component_name}"
}, {
"name": "Component Message",
"value": "${component_message}"
}, {
"name": "Detailed Error",
"value": "${detailed_error}"
}],
"markdown": false
}]
}
Hi both, you are right, the dollar sign is important when adding variable name in Payload variable sections. I made that change however the other reason my payload was not working was because the variable I was trying to call which was a long sentence had inverted commas in the sentence e.g. There is a failure in "ABC Pipeline" which needs correction. I changed my variable be replacing inverted commas with apostrophise (') and it all started to work.
Really appreciate your help.
Thanks,
Raja
Hi Phil, many thanks for your kind reply. Unfortunately, it is still not working for me. I have changed the payload as per below:
and I am getting the output in teams as per below:
I have also tried to change the payload variable setting in webhook properties by adding a dollar sign there but it gives me an error. See below for details:
I also changed single quotes to double in the payload to see if that may work but all in vain.
Not sure what the issue is. Any further help would be much appreciated. Thanks