I am new to postman and i wanted to compare two responses from different API

Wanted to compare two responses from different API But i am facing issue :-

Response 1 :-
{
“errorDescription”: “”,
“message”: “”,
“resultCode”: “OK”,
“resultObj”: {
“ip”: “192.168.7.60”,
“x-up-forwarded-for”: “”,
“port”: “43307”
}
}

Response 2 :
{
“resultCode”: “OK”,
“errorDescription”: “”,
“message”: “”,
“resultObj”: {
“ip”: “10.0.0.4”,
“port”: null,
“x-up-forwarded-for”: “”
},
“systemTime”: 1533906004
}

Here we are comparing all the keys present in both the responses but i am not able to compare it. I want to compare 1st and 2nd response and if anything is missing in 2nd response from 1st response then fail the test including keys inside the resultObj.
Please help me out it will be a great help

@farhan.quidwai This use case can be satisfied via response assertions, as follows:

Inside the test script for request 1:

pm.environment.set('res1', pm.response.text());

Inside the test script for request 2:

pm.test('should have identical responses', () => {
  pm.response.to.have.body(JSON.parse(pm.environment.get('res1')));
});
1 Like

hey @kunagpal Thanks for your response , i want to ignore the systemTime in my assertion part ? is that possible to ignore the systemTime and check for the rest of the values ?