# Dynatrace Synthetic pre-post scripting

**URL:** <https://community.dynatrace.com/t/dynatrace-synthetic-pre-post-scripting/21225>\
**Category:** Synthetic Monitoring\
**Tags:** synthetic-monitoring\
**Created:** [January 18, 2021, 8:54pm UTC](https://community.dynatrace.com/t/dynatrace-synthetic-pre-post-scripting/21225 "2021-01-18T20:54:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [January 18, 2021, 8:54pm UTC](https://community.dynatrace.com/t/dynatrace-synthetic-pre-post-scripting/21225/1 "2021-01-18T20:54:54Z")

</div>

Hi all.

I need to create a Dynatrace Synthetic monitor to perform two requests, a POST and then a GET.  
Inside the POST “requestBody” I need to pass an INT value, maybe using the api.randomNextInt().  
Then the GET request need to use the same INT value generated to validate the response, to pass if present, into validation - rules - value field.  
Is this possible? To use the variables into the POST requestbody, and on GET validation?  
Can someone help me to set up this script properly?

Thanks.

---

<div class="post-metadata">

**Author:** ![skrystosik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/skrystosik/32/21133_2.png) [@skrystosik](https://community.dynatrace.com/u/skrystosik)\
**Post date:** [January 21, 2021, 8:43am UTC](https://community.dynatrace.com/t/dynatrace-synthetic-pre-post-scripting/21225/2 "2021-01-21T08:43:12Z")

</div>

Here you have some info about passing variables. When you set one on request 1, you should be able to use it in request 2:

> **[Pre- and post-execution scripts for HTTP monitors in Classic](https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/http-monitors-classic/pre-and-post-scripting-for-http-monitors-classic)**
>
> Learn how to apply pre and post scripts to your requests

Sebastian
