代码如下:
//定义需要测试的API
var formdata_api_demo_1 = {
"url": `47.95.203.198:8080/Web/Test/body/print`, //[必填][string]请求地址,若不存在请求协议,默认http
"name": "FORM-DATA API Demo", //[选填][string],API名称,方便检索,不填则默认为系统生成API编号
"method": "POST", //[选填][string],请求方式,可能值有[GET/POST/PUT/PATCH/DELETE/HEAD/OPTION],兼容大小写,默认为GET
"headers": {
"Content-Type": "application/json"
}, //[选填][object],请求头部
"bodyType": "json", //[选填][string],请求体类型
"body": [{ //[选填][object],请求参数
"school_id":"1",
"school_name":"北京大学1",
"school_type":"大学1",
"username":"lisa1"
},
{ //[选填][object],请求参数
"school_id":"2",
"school_name":"北京大学2",
"school_type":"大学2",
"username":"lisa2"
}],
"timelimit": "follow" //[选填],超时限制,单位为ms,超过时间则判断为请求失败,默认为1000ms
};
//执行请求,返回格式为{time:“请求时间”,code:“HTTP状态码”,response:“返回结果”,header:“返回头部”},
var formdata_api_demo_1_result = eo.execute(formdata_api_demo_1);
//判断返回结果
if (formdata_api_demo_1_result.response !== "") {
var rp=eo.json.decode(formdata_api_demo_1_result.response)
eo.info(rp); //输出信息
eo.info(rp[0].school_id);
} else {
eo.info("info_2"); //输出信息
}
let idarr = [];
let namearr = [];
rp.forEach(function(val) {
eo.info("message");
idarr.push(val.school_id)
namearr.push(val.school_name)
// eo.info(idarr[0])
eo.info(namearr)
//eo.info(queryArr[0].school_name)
})
for (var i = 0; i < idarr.length; i++) {
var result_oracle_1=eo.mysql({
"dbID":"eo_db_id_529",
"name":"myaql"
},insert into school_qutest(school_id,school_name)values(
+idarr+,'
+namearr+')
)
}