var count = 1;
//把参数封装成数组对象,然后遍历去发送请求
var arrpra = [{ "shopId": "PH100902", "shopName": "Pozorrubio 3-PCC Zone-PCC Zone-Pozorrubio-Pangasinan-PH", "activityId": 114, "OnOffId": 1 },
{ "shopId": "PH101029", "shopName": "Binalonan-Addessa Corporation-Addessa Corporation-Binalonan-Pangasinan-PH", "activityId": 114, "OnOffId": 1 },
{ "shopId": "0301000174", "shopName": "Waltermart Paniqui Tarlac-Abenson-Abenson-Paniqui-Tarlac-PH", "activityId": 114, "OnOffId": 1 },
{ "shopId": "0301000279", "shopName": "Paniqui Tarlac-Fairpay WH-Fairpay-Paniqui-Tarlac-PH", "activityId": 114, "OnOffId": 1 },
{ "shopId": "0301000534", "shopName": "Megamart Paniqui Tarlac-Flexifone-Rex Cellphone Shop-Paniqui-Tarlac-PH", "activityId": 114, "OnOffId": 1 },
{ "shopId": "0301000610", "shopName": "Paniqui Tarlac-Flexifone-Rex Cellphone Shop-Paniqui-Tarlac-PH", "activityId": 114, "OnOffId": 1 }
];
for (var i = 0; i < arrpra.length; i++) {
//封装请求参数和请求头
var regRequest = {
url: 'https://drp-operation-apac-api.myoppo.com/drp/reservation-apac/admin/reservation/activityShops/OnOrOffOneShop',
method: 'POST',
header: ['Content-Type:application/json', 'app-id:42', 'x-country-two-code:PH', 'x-authority-id:161570', 'token:a775f48c35091d56637bbddde7b9b284be1a02c69613d968172d512245403792'], //注意要在Header中声明内容使用的类型
body: {
mode: 'raw', // 使用raw(原始)格式
raw: JSON.stringify(arrpra[i]) //要将JSON对象转为文本发送
}
}
//发送请求
pm.sendRequest(regRequest, function (err, res) {
if (!err) {
count++;
console.log(count);
} // 响应为JSON格式可以使用res.json()获取到JSON对象
})
}
postman脚本批量请求
于 2022-03-18 00:14:48 首次发布