# iterationData for csv files. using Newman as programmatically not CLI

**URL:** <https://community.postman.com/t/iterationdata-for-csv-files-using-newman-as-programmatically-not-cli/8464>\
**Category:** Help Hub\
**Tags:** newman-project\
**Created:** [October 20, 2019, 8:08pm UTC](https://community.postman.com/t/iterationdata-for-csv-files-using-newman-as-programmatically-not-cli/8464 "2019-10-20T20:08:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trisha1212](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/trisha1212/32/4651_2.png) [@Trisha1212](https://community.postman.com/u/Trisha1212)\
**Post date:** [October 20, 2019, 8:08pm UTC](https://community.postman.com/t/iterationdata-for-csv-files-using-newman-as-programmatically-not-cli/8464/1 "2019-10-20T20:08:19Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

Not able to use iteration data while calling a PUT API

- My API `{{myurl}}/api/layouts/{{id}}` - `{{myurl}}` is environment, and `{{id}}` i am reading from CSV file

- Using Newman as programmatically  
`var newman = require('newman'); var fs = require('fs'); newman.run({ collection: require('./putlayout.postman_collection.json'), environment: require('./local.postman_environment.json'), iterationCount :2, iterationData: require('./id.csv'), insecure: true, reporters: 'cli', }).on('console', function (err, logs) { console.log(logs.messages); });`

- Error i am facing : /Users/chetatri/Desktop/gtmhub/newman/id.csv:1  
70b2ae4e-f421-4af8-8593-b40355ad08c2  
^^  
SyntaxError: Invalid or unexpected token  
70b2ae4e-f421-4af8-8593-b40355ad08c2  

- csv file used  
(base) ESZAR1M0186:newman chetatri$ cat id.csv  
id  
9ef99ac4-b2dc-4943-a562-e292f7bd12c7  
a8e0dadd-7257-4e6b-937d-b22b8509a508  
(base) ESZAR1M0186: Newman chetatri$

- Example for JSON is available  
:` iterationData: [{ “var”: “data”, “var_beta”: “other_val” }],`

---

<div class="post-metadata">

**Author:** ![amit](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/amit/32/2056_2.png) [@amit](https://community.postman.com/u/amit)\
**Post date:** [October 20, 2019, 11:27pm UTC](https://community.postman.com/t/iterationdata-for-csv-files-using-newman-as-programmatically-not-cli/8464/2 "2019-10-20T23:27:24Z")

</div>

Try the following and see if that helps:

```
newman.run({ 
    collection: require('./putlayout.postman_collection.json'),
    environment: require('./local.postman_environment.json'), 
    iterationData: './id.csv', 
    insecure: true, reporters: 'cli', 
}).on('console', function (err, logs) { console.log(logs.messages); });

```

I’ve removed `require()` function for `iterationData` field’s value, and that seems to have done the trick!

I actually checked by removing `require()` function for Collection and Environment as well, and that works as well.

---

<div class="post-metadata">

**Author:** ![nborets](https://avatars.discourse-cdn.com/v4/letter/n/f1d935/32.png) [@nborets](https://community.postman.com/u/nborets)\
**Post date:** [March 13, 2020, 4:23pm UTC](https://community.postman.com/t/iterationdata-for-csv-files-using-newman-as-programmatically-not-cli/8464/3 "2020-03-13T16:23:26Z")

</div>

That’s solution helped me for that problem! Many thanks!

---

<div class="post-metadata">

**Author:** ![bmead0349](https://avatars.discourse-cdn.com/v4/letter/b/90db22/32.png) [@bmead0349](https://community.postman.com/u/bmead0349)\
**Post date:** [July 20, 2021, 11:47pm UTC](https://community.postman.com/t/iterationdata-for-csv-files-using-newman-as-programmatically-not-cli/8464/4 "2021-07-20T23:47:35Z")

</div>

This works for me as well! What would cause that!? Require is only for importing json?

---

<div class="post-metadata">

**Author:** ![maintenance-special3](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@maintenance-special3](https://community.postman.com/u/maintenance-special3)\
**Post date:** [March 16, 2022, 5:11pm UTC](https://community.postman.com/t/iterationdata-for-csv-files-using-newman-as-programmatically-not-cli/8464/5 "2022-03-16T17:11:43Z")

</div>

Thanks a lot! That helped me!
