How to write different tests to validate each iteration response on Single request-POST request-Postman

Hi, I have a single POST request to which I pass 8 different sets of data while running collection using csv or json file.

“Id” : "{{ID}},
“name”: {{name}},
“email” : {{email}},
“phn” : {{phn}}
all fields are mandatory and i want to check mandatory error on leaving each field empty at each iteration.
I get Different response for each iteration and I want to validate my response message.
I need to validate a single line which looks like

var messageDetail = pm.response.json().MessageDetail
pm.test(“message”, function(){
pm.expect(messageDetail).to.equal.(“output which is different on each iteration”);

can anyone tell me how to do this, please??

Yes, you can use the CSV file to define a new column, say “expected_result” and there you can put what you have expected.

Next use use the pm.iterationData.get(“expected_result”) to fetch the value:


Hi vdespa, thanks for your response,
But i am getting error on line
thier by i cannot add test like

pm.test(“MessageDetail”, function(){
Error in dev tools :
Invalid or unexpected token

  1. message:“Invalid or unexpected token”
  2. name:“SyntaxError”
  3. type:“Error”
  4. proto:Object, can you help me what causing it??

Can you share a screenshot with the error and you code?

Hi vdespa,
Sorry, I did a mistake yesterday in tests tab. i figured it out. It is working absolutely fine now. Thanks a lot :slight_smile: