版权声明:本文为wcuu原创文章。 https://blog.csdn.net/wcuuchina/article/details/86592425
测试工具postmain 全局请求参数设置
Pre-request-Script中添加脚本
postman.setGlobalVariable("secretKey", "mysecret123456");
secretKey = postman.getGlobalVariable("secretKey");
上面表示请求设置一个安全的key
postman.setGlobalVariable("time", Math.round(new Date().getTime()));
time = postman.getGlobalVariable('time');
// 设置一个时间 - 需要注意的是,这里设置过时间后,当前时间在请求时时不会变的, 如果请求接口签名会有时间限制,则需要在调用的接口中单独设置时间参数。 也是在Pre-request-Script中添加当前脚本语句,因为Pre-request-Script在请求时才会触发。
在Header中的写法
{{time}}
扫描二维码关注公众号,回复:
5023496 查看本文章
---- Postman,header里面加时间戳的方法
{{$timestamp}}
# 这是默认10位的时间戳。位数大于10位则用0补全
{{$timestamp}}000
在Params中的写法
{{time}}
需要注意的是,设置全局后,需要发送请求
完毕!!!