Help, can we us CSV file data in Test Snippets, Just like we use to handle it when we pass through request body

Suppose I have 2 conditions to check in POSTMAN snippets, If I passed both the conditions through CSV file and in snippets I have declaired it as a Envirounment Variable will it work?

Yes you can access the CSV data in the Tests tab. No real need to declare as environment variables.

Importing data files | Postman Learning Center

Skip down to the section titled “Accessing data file values”.

Although there is another way, as detailed here. (Which is the method I use).

Using CSV and JSON Data Files in the Postman Collection Runner | Postman Blog

Read the section titled “Data variables in pre-request and test scripts”.

Thanks @mdjones can you please share one example how to declare it in Test tab with one example of CSV file. That would be really helpful

The link for the second method has an example CSV file that you should be able to follow with Postman echo.

Try and follow that example to learn how this works.

@mdjones I have tried with the method from link, but getting error as “An error occurred while running pre-request scripts for this request. Check Postman Console for more info.”
Kindly Help me on that


As I have not declaired userID as variable so getting error on that as well.



Please re-read the instructions.

Inside pre-request and test scripts, the special data dictionary contains values loaded from the data file for a specific iteration. For example data.username or data[‘username’] would let you access the value of the username variable from a data file.

So in the pre-request script, it would be data.user or data[“user”]

It should work fine in the URL, as you should be able to just reference it by {{user}}

Get it working in the console log first though.

User in URL still showing error after changes Please have a look



You can ignore the unresolved variable bit, as Postman won’t know about the value until its run in the Collection Runner. (Therefore it will always show unresolved).

@mdjones It works this time Thanks