13 Jun 2023 09:54 AM - last edited on 19 Jun 2023 07:37 AM by MaciejNeumann
I am creating a workflow that gets event details. It's very simple, here is the diagram and this is the code:
import { problemsClient } from '@dynatrace-sdk/client-classic-environment-v2';
export default async function ({ execution_id }) {
// get event context
var exec_req = await fetch(`/platform/automation/v0.1/executions/${execution_id}`)
var execution_obj = await exec_req.json()
return execution_obj
}
Advanced coding:
import { problemsClient } from '@dynatrace-sdk/client-classic-environment-v2';
export default async function ({ execution_id }) {
// get event context
var exec_req = await fetch(`/platform/automation/v0.1/executions/${execution_id}`)
var execution_obj = await exec_req.json()
// get problem
console.log("Loading Problem details...")
var event = execution_obj.params.event
var problem_request = { problemId: event['display_id'] }
var problem = await problemsClient.getProblem(problem_request)
console.log(`Problem ${problem.displayId}`)
return problem
}
As an example, I have looked at an image you have posted on the Dynatrace website, because in the documentation I can't find anything about how to capture these events from a workflow.
My problem is that even though the execution_id of the previous run gets it right, then it tells me that the object is empty --> execution_obj.params
Could someone help me with this issue? where is there documentation on this issue and how to process a previous event? Thank you very much
Bonus: I tested with this code example, adding the event id by hand, and it works perfectly.
import { problemsClient } from '@dynatrace-sdk/client-classic-environment-v2';
export default async function ({ execution_id }) {
// get problem
console.log("Loading Problem details...")
var problem_id = "-123456789V2"
var problem_request = {problemId: problem_id}
var problem = await problemsClient.getProblem(problem_request)
console.log(`Problem ${problem.displayId}`)
return problem
}
Solved! Go to Solution.
14 Jun 2023 12:20 PM
Is working:
var exec_req = await fetch(`/platform/automation/v1/executions/${execution_id}`)
the version is v1
16 Jun 2023 12:27 PM
Typo:
var problem_request = { problemId: event['event.id'] }