# Display variable content in Response Handling text

**URL:** <https://community.postman.com/t/display-variable-content-in-response-handling-text/9588>\
**Category:** Help Hub\
**Tags:** collection-runner\
**Created:** [December 13, 2019, 8:50am UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588 "2019-12-13T08:50:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![vwsamba21w](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@vwsamba21w](https://community.postman.com/u/vwsamba21w)\
**Post date:** [December 13, 2019, 8:50am UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/1 "2019-12-13T08:50:00Z")

</div>

Take a normal Response Handling statement:

```auto
    pm.test("response is ok", function () {
        pm.response.to.have.status(200);
    });

```

I would like to customize the text with a variable coming from a Data Input File:

```
pm.test("response FOR CUSTOMER " + {{path}} + " is ok", function () {
    pm.response.to.have.status(200);
});

```

In Collection Runner I open an input file that populates the variable path.  
This means the variable path is undefined at the start, it is populated at run time.

My URL is:

`https://tapy-uat.flyrit.de/clm/unbprocessor/sales/pt/identifiers/no={{path}}`

My input file:

```auto
> path
> 4567459687
> 4357349584
> 2396504398
> 4572839495

```

With the first Response Handling statement (without ‘path’ in the text, see top of my post) the execution is perfect, the variable path is read from the input file, populates the URL and executes as expected.

As soon as I try to include the variable “path” to leave information in the Response Handling statement text, I get an error and the variable is displayed as **undefined** (only in the text, the url is still working fine)

I cannot use

```auto

> pm.environment.get("path")

```

since “path” is not an environment variable, it is undefined at start populated first at run time

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [December 13, 2019, 4:02pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/2 "2019-12-13T16:02:51Z")

</div>

Hi @vwsamba21w

Welcome to the community!

I think I see what your issue is here.

Have you tried accessing the variable in your script by using the “data” variable?

if you want to get the path to output, and path is a column in your data file, it looks like all you would need to do is data.path, so that your code would look like so:

`pm.test("response FOR CUSTOMER " + data.path.toString() + " is ok", function () { pm.response.to.have.status(200); });`

I referred to their docs here to get this.

[https://learning.getpostman.com/docs/postman/collection-runs/working-with-data-files/](https://learning.getpostman.com/docs/postman/collection-runs/working-with-data-files/)

Let us know if it worked!

— Orest

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [December 13, 2019, 4:48pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/3 "2019-12-13T16:48:44Z")

</div>

Hey @vwsamba21w

You should be able to use `pm.iterationData.get('path')` in the test name.

```
pm.test(`response FOR CUSTOMER ${pm.iterationData.get('path')} is ok`, function () {
    pm.response.to.have.status(200);
});
```

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [December 13, 2019, 8:37pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/4 "2019-12-13T20:37:18Z")

</div>

Ah @danny-dainton I was looking for this in the documentation as well! I knew I have seen it before, but couldn’t remember where I saw it.

Would it be possible to add this way of getting iteration data into the Learning Postman Docs?

Thanks in advance,  
— Orest

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [December 13, 2019, 8:43pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/5 "2019-12-13T20:43:38Z")

</div>

You will be able to find that here 😁

[https://learning.getpostman.com/docs/postman/scripts/postman-sandbox-api-reference/#pmiterationdata](https://learning.getpostman.com/docs/postman/scripts/postman-sandbox-api-reference/#pmiterationdata)

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [December 13, 2019, 8:55pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/6 "2019-12-13T20:55:35Z")

</div>

Awesome! I have never seen this before.

Maybe a link between the two? 🤔

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [December 13, 2019, 9:07pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/7 "2019-12-13T21:07:30Z")

</div>

The docs are all open source and we’d love you to submit a PR for that suggestion 🙂

Would be a great addition. 🏆

> **[GitHub - postmanlabs/postman-docs: Documentation for Postman, a collaboration...](https://github.com/postmanlabs/postman-docs)**
>
> Documentation for Postman, a collaboration platform for API development. Available for Mac, Windows, and Linux. - GitHub - postmanlabs/postman-docs: Documentation for Postman, a collaboration platf...

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [December 13, 2019, 11:04pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/8 "2019-12-13T23:04:15Z")

</div>

Agreed! Looks like it’s time for my first PR! 😊

---

<div class="post-metadata">

**Author:** ![vwsamba21w](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@vwsamba21w](https://community.postman.com/u/vwsamba21w)\
**Post date:** [January 8, 2020, 2:43pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/9 "2020-01-08T14:43:59Z")

</div>

Hi odanylewycz,

This worked like a charm. THANKS A LOT! 😀

---

<div class="post-metadata">

**Author:** ![vwsamba21w](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@vwsamba21w](https://community.postman.com/u/vwsamba21w)\
**Post date:** [January 8, 2020, 2:45pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/10 "2020-01-08T14:45:05Z")

</div>

Hi dannydainton,

Unfortunately I couldn’t put your suggestion to work. Thanks anyway for trying.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 8, 2020, 2:49pm UTC](https://community.postman.com/t/display-variable-content-in-response-handling-text/9588/11 "2020-01-08T14:49:07Z")

</div>

That’s strange ☹ - Was there a particular error message that was returned when you tried using this? Interesting to see where it’s failing for you. 🤔

The `pm.iterationData` function has been part of the app for a while now and is the best thing to use when working with data files loaded in from the Collection Runner.
