本文主要是介绍使用postman请求x5接口,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
x5接口简介
1.接口样例
{"header"{"appid":"bpmnew_fanwei","sign":"C033162E86E4CADE80C7EB44D68A5AD2","sign_type":"md5","url":"https://oa.mioffice.cn/api/bpm/xm/app/show/todoflow","method":""},"body":"{\"pageSize\":\"30\",\"userName\":\"liumingtao\",\"title\":\"\",\"currentPage\":\"1\",\"procDefIdPrefix\":\"65\"}"}
2.Base64加密、解密
- 入参:参数形式:{‘header’:{‘appid’:’’,’sign’:’’},’body’:’’}
- {"header":{"appid":"bpmnew_fanwei","sign":"5BE3B9F908ED976050D1204B257D84DC","sign_type":"md5","url":"https://oa.mioffice.cn/api/bpm/xm/app/show/workflow","method":""},"body":"{\"loginid\":\"liumingtao\"}"}
- data后面的入参为接口入参加密后的数据
3.sign生成方法:
- MD5:加密:http://www.bejson.com/enc/md5/‘
- bpmnew_fanwei{"loginid":"liumingtao"}8150ACDEBB42C288F1293F8C5AF2CEF1:{"loginid":"liumingtao"}为body里的入参
步骤
步骤1:复制代码到 pre-request script中
var x5 = {
run: function(appid,appkey) {
if (typeof appid == "undefined") {
appid = pm.environment.get("appid");
}
if (typeof appkey == "undefined") {
appkey = pm.environment.get("appkey");
}
var self = this;
var tmpArr = {};
var reqData = request.data;
if (_.isObject(reqData)) {
var keys = _.sortBy(_.keys(reqData));
_(keys).forEach(function(key) {
tmpArr[key] = reqData[key];
}).value()
}
delete tmpArr.data;
var json_body = JSON.stringify(tmpArr).replace(/\\\\u/g, '\\u');
var sign = CryptoJS.MD5(appid + json_body + appkey, {asString: true}).toString().toUpperCase();
var data = {
header :{
appid : appid,
sign : sign
},
body : json_body
};
data = JSON.stringify(data).replace(/\\\\u/g, '\\u');
pm.globals.set("data", CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(data)));
}
}
x5.run();
步骤2:添加环境变量
步骤3:输入请求信息
步骤4:选择环境变量
这篇关于使用postman请求x5接口的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!