在Postman中将body元素指定为环境变量

在Postman中将body元素指定为环境变量,postman,Postman,我有一个场景,需要将body元素值传递给environmen变量,并在另一个API中访问它 下面是身体, { "firstName" : "James", "lastName" : "Joseph", "email" : "{{timestamp}}@test.com", "password" : "{{timestamp}}", "country" : 16 } 下面是Pre-req脚本 postman.setEnvironmentVariable("timestamp", (new Da

我有一个场景,需要将body元素值传递给environmen变量,并在另一个API中访问它

下面是身体,

{
"firstName" : "James",
"lastName" : "Joseph",
"email" : "{{timestamp}}@test.com",
"password" : "{{timestamp}}",
"country" : 16
}
下面是Pre-req脚本

postman.setEnvironmentVariable("timestamp", (new 
Date).getTime());
// I have copied the Body and paste it in a variable called Obj in Pre- 
req
// Then i used the below script to get the body
pm.environment.set("rawBody", JSON.stringify(obj));
但时间戳、电子邮件和密码的环境值如下。时间戳值正确,其他两个值错误

timestamp = 1566076106769
email = {{timestamp}}@test.com
password = {{timestamp}}
时间戳值在电子邮件和密码中未被替换,我希望环境变量值设置为

email = 1566076106769@test.com
password = 1566076106769
那么,如何将body元素值分配给环境/全局变量,以便在另一个API调用中使用?

可能重复的