I have a case where Iβm trying to re-issue the previous test with slightly different variables so that I can compare the 2 responses. My specific case is that I have a request that has a skip/take parameter for records. I want to increment the skip by 1, do a second request and then verify that Iβm getting similar records, but that they are offset.
My problem is with trying to re-issue the request with a different body. It appears that this should work:
var requestBody = JSON.parse(pm.request.body.raw);
if(requestBody.hasOwnProperty("skip")){
var bodyCopy = Object.assign(requestBody, {skip: requestBody.skip+1});
var requestCopy = Object.assign({},pm.request);
requestCopy.body.raw = JSON.stringify(bodyCopy);
pm.sendRequest(requestCopy,(e,r)=>{
//do assertions here
console.log(r);
});
}
But it doesnβt seem to do the trick. Is there a quick way to re-issue the previous request with slight modifications, without having to totally deconstruct and reconstruct it?