pm.request
to read or modify request messages.// pm.variables.replaceIn: handling variables in parameters
var body = pm.variables.replaceIn(pm.request.body.raw);
var jsonData = JSON.parse(body);
Variable Substitution
, which replaces all variables (including dynamic variables) in the request with the actual value.
pm.request.body
which is a RequestBody instance.var body = pm.request.body.toJSON();
console.log("body object", body);
var bodyStr = body.raw;
console.log("body string", bodyStr);
var bodyJSON = JSON.parse(bodyStr);
bodyJSON.id = 100;
pm.request.body.update(JSON.stringify(bodyJSON, null, 2));
console.log("Modified body", pm.request.body.toJSON());