Hi World ,
I want to create a workflow that will send problem details in JSON payload to another API. I tried this in payload
“ImpactedEntities”: {Stage}
but it is printing stage instead of picking value in variable stage .
I tried with and without double quotes
Try with
<span class="">"ImpactedEntities":</span> {{ <span class="">Stage</span> }}
Nope Not working on the other hand it is stating it is the wrong variable
I think this is the solution Jinja expressions for Workflows — Dynatrace Docs
so for accessing last stage data, I am using event
{{ event()[‘event.category’] }}
So finally I was able to make a payload and this is how it looks
{
"ImpactedEntities" : [{
"type" : "{{ event('affected_entity_types') }} " ,
"name" : "{{ event('affected_entity_ids') }}" ,
"entity" : "{{ event('affected_entity_ids' ) }}"
} ],
"ImpactedEntity" :{
"type" : "{{ event('affected_entity_types') | first }}" ,
"name" : "{{ event('affected_entity_ids') | first }}" ,
"entity" : "{{ event('affected_entity_ids') | first }}"
},
"PID" :"{{ event()['event.id'] }}" ,
"ProblemID" : "{{ event('display_id') }}" ,
"ProblemTitle" : "{{ event()['event.name'] | replace('\n', ' ') | replace('**', '') | replace('# ', '') }}" ,
"ProblemDetailsText" : "{{ event()['event.description'] | replace('\n', ' ') | replace('**', '') | replace('# ', '') }}" ,
"ProblemURL" : "https://{environmentid}.apps.dynatrace.com/ui/apps/dynatrace.davis.problems/problem/{{ event()['event.id'] }}" ,
"ProblemSeverity" : "{{ event()['event.category'] }}" ,
"State" : "{{ event()['event.status'] }}" ,
"tags" : {{ event().get('entity_tags','[]') | to_json }} ,
"ProblemDetailsJSONv2": {
"description": "{{ event()['event.description'] | replace('\n', ' ') | replace('**', '') | replace('# ', '') }}",
"title": "{{ event()['event.name'] | replace('\n', ' ') | replace('**', '') | replace('# ', '') }}",
"pid": "{{ event()['event.id'] }}",
"display_id": "{{ event('display_id') }}"
}
}