postman使用pre-request Script设置动态变量

      我们在本地调试接口时,有时接口使用的动态的参数,例如时间戳来进行参数加解密,这样这些参数就是动态的,这时我们就使用到了设置postman动态参数。

      在postman如图所示位置:

1.设置动态变量timestamp:

var timestamp = Math.round(new Date().getTime());
postman.setGlobalVariable("timestamp",timestamp);

2.请求时使用动态变量timestamp:

post请求: 取用示例:{{timestamp}}

post json请求:json字段中取值时,“{{timestamp}}”

猜你喜欢

转载自blog.csdn.net/qielanyu_/article/details/87824572