Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Postman Tutorial Part 42 – Create Parameterized Request by Reading Data From CSV in Postman – Make Selenium Easy

Posted on 05/19/2022 By admin

We have already learnt storing and accessing variables in different ways like Global variables, Environment variables, Collection variables etc in Postman. All these ways are like accessing variables from internal sources.

We may require to read data from external sources as well like csv or JSON in Postman. Not only this, it is useful to achieve data driven API automation testing as well. We will see everything in details.

We will cover how can we read data from CSV in Postman. Note here I am using term “CSV (Comma Separated Values) ” not “Excel”. There are many differences between a CSV and an Excel sheet. A CSV is a file formats that contain plain text values separated by commas. You can open any csv file in an excel as well as in a text editor. CSV is only capable of storing a single sheet in a file, without any formatting and formulas. Read more about Difference between an Excel and a CSV here.

Let’s understand a scenario:-

RestFul Booker provides an API to do booking which takes a JSON body as request to provide required details. I want all these values should come from a CSV file.

Let’s create a csv file to provide data :-

We can use an excel file and save it as csv file or we can use a text editor. Using a text editor is little difficult and confusing to create csv as a beginner. So I will suggest you to create a csv data file using excel.

There is some pattern to create a csv data file for Postman. The first row represents all variable names, and subsequent rows represent values for these variables. ( I am purposefully hiding an important term here for later understanding ). Let’s input values in excel first:-

You need to take care of number and boolean field. Add a single quote (‘) before passing value for numbers and boolean to maintain the formatting. You can notice above that value of “depositpaid” is converted to uppercase value of “true”. So to keep actual formatting add single quotes.

Now save above file as csv.

We are done now with creating csv. Second step is to parameterized request. Remember we can use csv variables in URL, headers, request , scripts etc as well. Here we are using in request body.

Using variables from csv file is same as any variable from Environment, global or collection i.e. as {{variableName}}.

Note:- If variable value is a string use put above in double quotes. If it is number of boolean , put it without double quotes. See example below:-

If we are reading data from a csv, we can not run it as a normal request by clicking on “Send” button. If we click on Send button to run above request, it will give you error “400 – Bad Request” because it will not able to get values for the variables defined. We have not told Postman where to look for values yet.

So we need to use Collection Runner for this. Save above request in a collection and launch collection runner. You can find all concepts of Collection and Collection RUnner on my blog here.

In Collection Runner, you will see a field named “Data” with “Select File”. Here you need to select csv file which we created above. Click on “Select File” button and select the csv file. You will see after selection, Data File type will automatically show as text/csv. You can preview the file.

Now run the collection by clicking on “Run ” button.

You will see Run result of Collection. You can see json request takes values from csv file.

You can find successful response as well:-

So we have read data from csv successfully.

You can download example csv from below link:-

DataForBookingHotelDownload

You can import example collection from here:-

https://www.getpostman.com/collections/c35399b642d3e5aa591f

#ThanksForReading

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Uncategorized

Post navigation

Previous Post: Selenium Topics Archives – Page 3 of 37 – Make Selenium Easy
Next Post: Advanced TestNG Tutorials 34: How To Pass a Group Name to be Run at Runtime in TestNG XML Using Beanshell – Make Selenium Easy

Related Posts

July 2018 – Make Selenium Easy Uncategorized
An Introduction to Selenium – A set of Tools Uncategorized
Bedsheet2 – Make Selenium Easy Uncategorized
June 2, 2019 – Make Selenium Easy Uncategorized
processes – Make Selenium Easy Uncategorized
npm Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark