# workflow with http request

**URL:** <https://community.dynatrace.com/t/workflow-with-http-request/46169>\
**Category:** Automations\
**Tags:** workflows, automations\
**Created:** [June 18, 2024, 7:15am UTC](https://community.dynatrace.com/t/workflow-with-http-request/46169 "2024-06-18T07:15:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [June 18, 2024, 7:15am UTC](https://community.dynatrace.com/t/workflow-with-http-request/46169/1 "2024-06-18T07:15:27Z")

</div>

Good morning,

As shown below, it would be nice to use variables in the http request:

 ![henk_stobbe_0-1718694577183.png](https://global.discourse-cdn.com/dynatrace/original/1X/593bf7ef18ff3e89b22841a93f97c847338f2247.png)

So my questions is this possible, or do I need to write my own fetch request?

And I assume you need multiple returns for multiple variables or is the proper way state or document?

In short what is the proper way for this?

KR Henk

---

<div class="post-metadata">

**Author:** ![ChristopherHejl](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christopherhejl/32/20735_2.png) [@ChristopherHejl](https://community.dynatrace.com/u/ChristopherHejl)\
**Post date:** [June 18, 2024, 8:00am UTC](https://community.dynatrace.com/t/workflow-with-http-request/46169/2 "2024-06-18T08:00:14Z")

</div>

You can use the expressions documented at [https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference](https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference) as well as any default jinja2 function (link in the doc).  
We currently do not support defining a fixed set of variables on the workflow to use anywhere (although on the roadmap for this year with the proper introduction of workflow input support and default values in the UI).  
For now, if you want to manage a set of variables in one place to use throughout the workflow, your best bet would be an ad-hoc javascript task that returns the desired data.

Return data can be any json object, so complex, nested objects with any json supported types are possible. for example:

```javascript
export default async function ({ execution_id }) {

  return {
    my_string: "Some important string",
    my_number: 42,
    my_list: [1,2,"something else"],
    my_object: {
      my_key: "my value",
      my_other_number: 196,
      my_boolean: true
    }
  };

}

```

will return as shown

 ![ChristopherHejl_0-1718697341607.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/6/c680984bdb5b0bcdf5514678ec8d49d43881586e.png)

Then you can access the data using the result expression

```markup
{{ result("my_data_task")["my_object"]["my_key"] }}

```

 ![ChristopherHejl_1-1718697398124.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/6/563adf364bc0f6179d83eeabf7fa429793763bfd.png)

Note: in order to get proper autocomplete suggestion for the results, you’ll need to update the sample result of your custom javascript task accordingly.  
You can find that on the Sample Result tab

 ![ChristopherHejl_2-1718697460304.png](https://global.discourse-cdn.com/dynatrace/original/2X/1/17d7da162983a2b06b2637aeb2df5edfe3ceb880.png)

Then Edit and update the content.

 ![ChristopherHejl_3-1718697505708.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/0/f0549e0763bfe35a25dc1e77de81d1eb7fb52ff9.png)

Best way to do this I suggest to run the workflow once first, check the task works as expected and then use the “Sample from task exeuction” button which automatically updates the sample result with the result from the last execution:

 ![ChristopherHejl_4-1718697563975.png](https://global.discourse-cdn.com/dynatrace/original/2X/2/2f09bfc5afccf3e958240555a431433dde3fc24b.png)

-----  
Once we add full workflow input (and output) support, you will have a setting in the worklfow do define worklow scoped variables.

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [June 18, 2024, 8:06am UTC](https://community.dynatrace.com/t/workflow-with-http-request/46169/3 "2024-06-18T08:06:17Z")

</div>

Great lesson thanks! (-;

---

<div class="post-metadata">

**Author:** ![ChristopherHejl](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christopherhejl/32/20735_2.png) [@ChristopherHejl](https://community.dynatrace.com/u/ChristopherHejl)\
**Post date:** [June 18, 2024, 8:09am UTC](https://community.dynatrace.com/t/workflow-with-http-request/46169/4 "2024-06-18T08:09:34Z")

</div>

Thanks for the question!
