0
0
PostmanHow-ToBeginner ยท 4 min read

How to Use CSV with Collection Runner in Postman

To use a CSV file with Postman's Collection Runner, open the runner, select your collection, then upload the CSV file under the "Data" section. Postman will run the collection once for each row in the CSV, using the column headers as variable names.
๐Ÿ“

Syntax

The basic steps to use a CSV file with Postman Collection Runner are:

  • Select Collection: Choose the collection you want to run.
  • Upload CSV: Click "Select File" under the Data section and upload your CSV file.
  • Run Iterations: Postman runs the collection once per CSV row.
  • Use Variables: Use CSV column headers as variable names in your requests with {{variableName}} syntax.
text
Collection Runner UI Steps:
1. Open Postman
2. Click on "Runner" button
3. Select your collection
4. Under "Data", click "Select File" and upload your CSV
5. Click "Start Run"
๐Ÿ’ป

Example

This example shows a CSV file and how to use it in a Postman request.

CSV file (users.csv):

csv
username,email
alice,alice@example.com
bob,bob@example.com
๐Ÿ’ป

Example

In your Postman request URL or body, use variables like {{username}} and {{email}}. When you run the collection with the CSV, Postman replaces these with each row's values.

Request URL example: https://api.example.com/users?name={{username}}&email={{email}}

Running the collection will make two requests:

  • https://api.example.com/users?name=alice&email=alice@example.com
  • https://api.example.com/users?name=bob&email=bob@example.com
Output
Request 1: Pass if response OK for alice Request 2: Pass if response OK for bob
โš ๏ธ

Common Pitfalls

  • Incorrect CSV format: Ensure the CSV has headers and no extra commas.
  • Variable names mismatch: Variable names in Postman must exactly match CSV headers.
  • File encoding issues: Use UTF-8 encoding to avoid parsing errors.
  • Not using double curly braces: Always use {{variableName}} syntax in requests.
text
Wrong usage example:
Request URL: https://api.example.com/users?name=username&email=email

Right usage example:
Request URL: https://api.example.com/users?name={{username}}&email={{email}}
๐Ÿ“Š

Quick Reference

StepActionNotes
1Open Collection RunnerClick the Runner button in Postman
2Select CollectionChoose the collection to run
3Upload CSV fileClick 'Select File' under Data and upload CSV
4Use variablesUse {{columnName}} in requests matching CSV headers
5Start RunClick 'Start Run' to execute iterations
โœ…

Key Takeaways

Upload your CSV file in the Collection Runner's Data section to run data-driven tests.
Use {{variableName}} syntax in requests to access CSV column values.
Ensure CSV headers exactly match variable names used in your requests.
Each row in the CSV runs one iteration of the collection.
Check CSV format and encoding to avoid errors during the run.