【学习】apipost预执行脚本中发送一个请求的方法

发送from-data格式的请求

apt.sendRequest({

url:“http://127.0.0.1:8888/login”,

method:“POST”,

headers:{

“cookie”:“a=1;b=2”,

“content-type”:“multipart/form-data”

},

timeout:“25000”,

formData:{“name”:“xiaoming”,“pwd”:123}

}, function (response) {

console.log(response);

});


发送application/x-www-form-urlencoded格式的请求

apt.sendRequest({

url:“http://127.0.0.1:8888/login”,

method:“POST”,

headers:{

“cookie”:“a=1;b=2”,

“content-type”:“application/x-www-form-urlencoded”

},

timeout:“25000”,

form:“a=1”

}, function (response) {

console.log(response);

});


发送application/json格式的请求

apt.sendRequest({

url:“http://127.0.0.1:8888/login”,

method:“POST”,

headers:{

“cookie”:“a=1;b=2”,

“content-type”:“application/json”

},

timeout:“25000”,

body:"{a:1}"

}, function (response) {

console.log(response);

});


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容