07 Nov 2024 01:10 PM - last edited on 12 Nov 2024 01:59 PM by MaciejNeumann
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
Solved! Go to Solution.
07 Nov 2024 01:51 PM - edited 07 Nov 2024 01:51 PM
Try with
"ImpactedEntities": {{ Stage }}
07 Nov 2024 03:24 PM
Nope Not working on the other hand it is stating it is the wrong variable
I think this is the solution https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference#any-object
so for accessing last stage data, I am using event
{{ event()['event.category'] }}
11 Nov 2024 11:42 AM
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') }}"
}
}