# Postman Dependencies in Test Script

**URL:** <https://community.postman.com/t/postman-dependencies-in-test-script/5930>\
**Category:** Help Hub\
**Created:** [June 16, 2019, 8:21pm UTC](https://community.postman.com/t/postman-dependencies-in-test-script/5930 "2019-06-16T20:21:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton39](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Anton39](https://community.postman.com/u/Anton39)\
**Post date:** [June 16, 2019, 8:21pm UTC](https://community.postman.com/t/postman-dependencies-in-test-script/5930/1 "2019-06-16T20:21:29Z")

</div>

Hello folks,

I am new in postman.  
What I want to archieve is:  
When I test the API via postman, I can put external data like JSON

Imagine:  
You do a request to an API, which delivers you an attribute, which you will need for another request like:

someId = 12345

You need this value, to request another API.  
Is there a way, how I can do dependencies in collection tests with external files?  
That I can also store the result for example temporary for another request?

Thanks

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [June 17, 2019, 7:07am UTC](https://community.postman.com/t/postman-dependencies-in-test-script/5930/2 "2019-06-17T07:07:24Z")

</div>

Hi Anton,

We usually use a variable to store data that is passed from one request to the other.

Using files is rather complicated as Postman has limited access to the filesystem.

---

<div class="post-metadata">

**Author:** ![Anton39](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Anton39](https://community.postman.com/u/Anton39)\
**Post date:** [June 17, 2019, 7:22am UTC](https://community.postman.com/t/postman-dependencies-in-test-script/5930/3 "2019-06-17T07:22:52Z")

</div>

Thank you.

Do you have an example, how to do this?  
Like calling API one, safe data and put it to another one?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![chrissbaumann](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/chrissbaumann/32/5521_2.png) [@chrissbaumann](https://community.postman.com/u/chrissbaumann)\
**Post date:** [June 17, 2019, 9:04am UTC](https://community.postman.com/t/postman-dependencies-in-test-script/5930/4 "2019-06-17T09:04:59Z")

</div>

Hi @Anton39,

I think this article explains what you´re looking for: [https://blog.getpostman.com/2014/01/27/extracting-data-from-responses-and-chaining-requests/](https://blog.getpostman.com/2014/01/27/extracting-data-from-responses-and-chaining-requests/)

Best,  
Christian

---

<div class="post-metadata">

**Author:** ![aamir.ahmed](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@aamir.ahmed](https://community.postman.com/u/aamir.ahmed)\
**Post date:** [June 17, 2019, 9:26am UTC](https://community.postman.com/t/postman-dependencies-in-test-script/5930/5 "2019-06-17T09:26:53Z")

</div>

Hi @Anton39,

You can use Global variables as well as environment variables to store the data you have received as a response for the next request based on your requirements.

1. **Global Variables** : Save the value retrieved from the JSON response as a global variable.These values will be available across all environments. Given below is an example for the same:

Example JSON response:

{

“responseTime”: “100”

}

Usage: **pm.globals.set(“variable\_key”, pm.response.json().responseTime);**

1. **Environment Variables** : Save the value retrieved from the JSON response as an environment variable. These values will be available in a specific environment which you have selected as shown in the attached image:  
 ![ManageEnvironments](https://us1.discourse-cdn.com/getpostman/original/3X/3/8/38fe33450252f8be60a5855d0f434e167bd748dc.png)

Example JSON response:

{

“responseTime”: “100”

}

Usage: **pm.environment.set(“variable\_key”, pm.response.json().responseTime);**

To get a detailed understanding on how to use Global and environment variables, have a look at the following link: [https://learning.getpostman.com/docs/postman/environments\_and\_globals/intro\_to\_environments\_and\_globals/](https://learning.getpostman.com/docs/postman/environments_and_globals/intro_to_environments_and_globals/)
