我正在与Postman一起工作,并且有一种情况,我需要将主体值传递给环境变量,并在另一个API中获取它们。
出于测试目的,我们将“电子邮件”和“密码”硬编码为时间戳。
下面是身体
{
"firstName" : "ATFfristName",
"lastName" : "ATFlastName",
"email" : "{{timestamp}}@rty-xxxx.com",
"password" : "{{timestamp}}",
"country" : 80,
"policies" : 1
}
下面是Pre-req脚本,
postman.setEnvironmentVariable("timestamp", (new Date).getTime());
// I have copied the Bodyand 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}}@rty-xxx.com
password = {{timestamp}}
时间戳值未替换为电子邮件和密码,我希望将环境变量值设置为
email = 1566076106769@rty-xxx.com
password = 1566076106769
那么我如何将body元素值分配给环境/全局变量以在另一个API调用中使用?