Passing whole response of first request to second request body

Hi Team, I have two requests I should pass all the response values from the first to the second request body area.
I have created a variable called “response2” and set the response in a variable, but when I am passing a response value in the second request body. i am getting some errors and looks like value is not passed from first request response

1 request tests area :

if (pm.response.code == 200 ) {

pm.test(“search contract is successful”, function () {
var jsonData = pm.response.json();
pm.globals.set(“response2”, jsonData);
console.log(pm.globals.get(“response2”));
});
}

Second request body area ;

{
“policy”:
“{{response2}}”,
“documents”: [
{
“name”: “Änderungantrag”,
“created”: “2020-10-16T07:55:14.472Z”,
“contactId”: “123123-asdasd2-asdasd2”,
“issueId”: “asdlhasd-das2-das2”,
“sender”: “POLICYHOLDER”,
“fileReference”: “ioasdjasfhoiashf21asinfoaisdj”,
“isSigned”: true,
“fileMimeType”: “pdf”
}
]
}

Hello @jayaveljays,similar thread is discussed here.

You should try

if (pm.response.code == 200 ) {

pm.test("search contract is successful", function () {
var jsonData = pm.response.json();
pm.globals.set("response2", JSON.stringify(jsonData));
console.log(pm.globals.get("response2"));
});
}

P.S - Kindly drop in the detailed error messages/screenshots when you post for next time. Because just in an assumption I have provided the response here, to avoid it in future kindly go through this before raising a query :blush:

Please let me know if you have still issue with this :slight_smile:

Hi @bpricilla, I have applied the above code, still, the error is persisting.
when i checked the console. request body is not passed the value correctly. value is passed an object.

@jayaveljays Did you tried to see the value of “response2” variable in the console, also did you saved the request1 before running request 2 :slight_smile:?