How to access request body in postman

I have received few questions on how to access the Postman Request body in case we need to compare the request and response. So here is the quick answer, just use pm.request.body to access the request body.

For example you need to save User ID in variable and the you can verify the response on the basis of user id.

var jsonRequest = JSON.parse(pm.request.body.raw);
pm.environment.set("UserId", jsonRequest.UserId);

Leave a Reply

Your email address will not be published. Required fields are marked *