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

Calling the API to start a workflow, is there a way to add and consume parameters?

henk_stobbe
DynaMight Champion
DynaMight Champion

Hello,

Maybe I am overlooking, but how can I add parameters to the API to start a workflow?

And how do I consume these parameters in js?

KR Henk

3 REPLIES 3

sinisa_zubic
Dynatrace Champion
Dynatrace Champion

Hi @henk_stobbe 

as mentioned in help, have you checked out swagger about how to add parameters to the workflow execution?

sinisa_zubic_0-1717665604529.png

 

To access the input parameters, please have a look at this is the code snippet:

// optional import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';

export default async function ({ execution_id }) {
  // your code goes here
  // e.g. get the current execution
  const ex = await execution(execution_id);
  console.log('Automated script execution on behalf of', ex.trigger);
  console.log(ex.input);
  console.log(ex.params);
  return { triggeredBy: ex.trigger };
}

 

The parameters in that case will be logged to console.

 

Best,
Sini

Hi Sini,

Thanks for your reply,  I am very happy,

KR Henk

ChristopherHejl
Dynatrace Participant
Dynatrace Participant

I'd like to add that you can also access workflow inputs in any action without javascript using expressions as well https://docs.dynatrace.com/docs/shortlink/automation-workflow-expression-reference#execution 

 

# access the current execution object
{{ execution() }}

# access ID of current execution
Execution ID {{ execution().id }}

# access input of current execution
Execution input {{ execution().input | default('no input defined') }}

 

Featured Posts