一、设置全局变量
二、Body中引用全局变量
{
"clientId": "15812345678",
"timestamp": "{{timestamp}}",
"sign": "{{sign}}",
"openId": "1",
"appid":"appid1",
"dataParams": {
"name":"111"
}
}
三、脚本代码
//let param = request.data; //post 参数
//let queryParam = pm.request.url.query.members; //get中的参数
//pm.request.addQueryParams("time=" + (new Date()).getTime().toString());
let timestamp = (new Date()).getTime().toString();
let jsonObj = {"clientId":"15812345678","privateKey":"123456","timestamp":timestamp};
let jsonStr = JSON.stringify(jsonObj);
// console.log(jsonStr);
let md5Str = CryptoJS.MD5(jsonStr).toString().toUpperCase();
// console.log(md5Str);
// 设置时间戳
pm.environment.set("timestamp", timestamp);
// 设置签名
pm.environment.set("sign", md5Str)
版权归原作者 雨落星辰C 所有, 如有侵权,请联系我们删除。