To assert a response in postman, you need to first understand how to store the request data into environment variables. You can see my other post here to understand the same.

Once you are set with your request data, we will now hit a sample request and then validate the response against the request data.There are some pre-defined snippets in provided by postman that you can use to validate your basic validations like status code, content-type and so on.

To use the pre-defined go to the “Tests” section in the postman tool and you will see list of all the pre-defined snippets on the right hand side.

To add any of the pre-defined snippets just click on any of options and the same will get added in the “Tests” section of the request.For example to add the status code check snippet just click on the option and you will see below code gets added.

// To verify the content type in Header 
pm.test("Content-Type is present", function () {"Content-Type"); });
//To verify the status code
pm.test("Status code is 200", function () {;

To validate any custom response to first need to store the response body into a variable and then use the “===” to compare the response variable and the store environment variable.

// Store the response into a variable

var responseData = JSON.parse(responseBody);

//Below is the assertions code

tests["verify the employee ID"] = === pm.environment.get("Employee_ID"); tests["verify the employee First Name"] = === pm.environment.get("employe_firstName"); tests["verify the employee Last Name"] = === pm.environment.get("employe_lastName"); tests["verify the employee Middle Name"]= === pm.environment.get("employe_middleName");