# How to reference to variable from file in newman?

**URL:** <https://community.postman.com/t/how-to-reference-to-variable-from-file-in-newman/20123>\
**Category:** Help Hub\
**Created:** [February 6, 2021, 7:33pm UTC](https://community.postman.com/t/how-to-reference-to-variable-from-file-in-newman/20123 "2021-02-06T19:33:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![science-explorer-112](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@science-explorer-112](https://community.postman.com/u/science-explorer-112)\
**Post date:** [February 6, 2021, 7:33pm UTC](https://community.postman.com/t/how-to-reference-to-variable-from-file-in-newman/20123/1 "2021-02-06T19:33:22Z")

</div>

Hi,  
i test the newman feature and love it. but I have one question I can’t figure out:

> **[Running collections on the command line with Newman](https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/#getting-started)**

Here’s an example of the CSV file for the above set of variables:

```auto
url, user_id, id, token_id
http://127.0.0.1:5000, 1, 1, 123123123
http://postman-echo.com, 2, 2, 899899

how to I reference to these columns?

I know how to reference to environment variable by using {{}}

Thank you!

```

---

<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:** [February 6, 2021, 8:45pm UTC](https://community.postman.com/t/how-to-reference-to-variable-from-file-in-newman/20123/2 "2021-02-06T20:45:06Z")

</div>

You would just do the same thing for those columns headings, in the Collection.

For example:

If you use them in the URL, Params or Headers, it’s `{{url}}` or `{{user_id}}`.

If you use them in the scripts, it’s `pm.iterationData.get('url')`

---

<div class="post-metadata">

**Author:** ![science-explorer-112](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@science-explorer-112](https://community.postman.com/u/science-explorer-112)\
**Post date:** [February 6, 2021, 10:54pm UTC](https://community.postman.com/t/how-to-reference-to-variable-from-file-in-newman/20123/3 "2021-02-06T22:54:43Z")

</div>

Thank you for your reply. still not working:

The data.csv file has two lines, and when I ran following command line, it iterate twice, which is good

newman run postman\_collection.json --folder Inventory -e postman\_environment.json --reporters cli,json --reporter-json-export outputfile.json -d data.csv

csv file contains 2 lines (don’t count the header):  
ID  
111  
222

in the web service request I tried both {{ID}}, and pm.iterationData.get(‘ID’), both give me a 500 error.

if I hardcode 111 in the web service request, server return result as expected.  
111

---

<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:** [February 6, 2021, 11:18pm UTC](https://community.postman.com/t/how-to-reference-to-variable-from-file-in-newman/20123/4 "2021-02-06T23:18:45Z")

</div>

What does that like look in the UI? Showing an image of where you put those variables is a lot easier that trying to describe it 😁

Does this work with the Collection Runner, if it does, then it will work with Newman.

---

<div class="post-metadata">

**Author:** ![science-explorer-112](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@science-explorer-112](https://community.postman.com/u/science-explorer-112)\
**Post date:** [February 6, 2021, 11:46pm UTC](https://community.postman.com/t/how-to-reference-to-variable-from-file-in-newman/20123/5 "2021-02-06T23:46:30Z")

</div>

Please see the picture 🙂 Thank you!

 ![postman](https://us1.discourse-cdn.com/getpostman/original/3X/f/3/f32023fa33b97eac0a341fab9a84355c7800f41e.jpeg)

---

<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:** [February 7, 2021, 7:12am UTC](https://community.postman.com/t/how-to-reference-to-variable-from-file-in-newman/20123/6 "2021-02-07T07:12:43Z")

</div>

This is talking about a single request and using an environment variable.

Can you Run this collection, in the Runner and use the same CSV data file to resolve the ID value?
