我有一种情况,我需要将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,email和password的环境值如下。时间戳记值正确,另外两个错误。
timestamp = 1566076106769
email = {{timestamp}}@test.com
password = {{timestamp}}
时间戳值未替换为电子邮件和密码,我希望将环境变量值设置为
email = 1566076106769@test.com
password = 1566076106769
那么我如何将body元素值分配给环境/全局变量以在另一个API调用中使用?