Make Selenium Easy

Postman Tutorial Part 50 – How to Retrieve Request Body in Postman

As a part of Postman Tutorial – End to End , in this post, we will learn “How to retrieve request body in Postman?”.

Verification is the purpose of testing. Suppose we need to create a booking and we pass required details like first name, last name, check in date, check out date etc. After booking we must need to verify if booking is done for passed data.

In Postman, we may require to fetch request data to assert with response data. For example:- Create Booking API requires a request body with below details like:-

And after hitting, we get below Response:-

Now we must cross verify details passed in request body are same as in response body.

We can get request JSON body in two ways:-

  1. var jsonReq = JSON.parse(pm.request.body.raw);
  2. var jsonReq1 = JSON.parse(request.data);

Now we can write json path to extract value and do all assertions.

Complete example is below:-

You can import example collection from here.

You can find all Selenium related post here.
You can find all API manual and automation related posts here.
You can find frequently asked Java Programs here.

Author: Amod Mahajan

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

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

Postman Tutorial Part 50 – How to Retrieve Request Body in Postman

by Amod Mahajan time to read: 1 min
0
%d bloggers like this: