cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to pass problem values to payload for API integration

siddharth
Newcomer_

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  


3 REPLIES 3

PacoPorro
Dynatrace Leader
Dynatrace Leader

Try with

"ImpactedEntities": {{ Stage }}

 

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'] }}

siddharth
Newcomer_

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') }}"
  }
}

 

Featured Posts