当前位置:网站首页>postman批量生产body信息(实现批量修改数据)

postman批量生产body信息(实现批量修改数据)

2022-04-23 14:04:00 学海无涯乐做舟

需求文档:更新候选人自定义信息

测试用例执行:用例信息

  • API接口

http://api-platform.staging-8.svc.k8s.staging.mokahr.com:8080/api-platform/v1/candidate/customField/update

  • Java内部接口

http://ats-candidate-offline.staging-8.svc.k8s.staging.mokahr.com:8080/api/inner/ats-candidate-offline/candidate/custom_fields/update

先通过API平台获取自定义字段信息

curl --silent --location --request GET 'http://api-platform.staging-8.svc.k8s.staging.mokahr.com:8080/api-platform/v1/candidates/custom_fields' \
--header 'Authorization: Basic bGl2aW5nc2ltcGxlOg==' \
--header 'Cookie: connect.sid=s%3AHH5fkO7fpcOSy1nt-zcAwsc8Dg9AZuMi.390HypGU2awXlNPhFmTaaWYbP%2FNS6bVmZBqnQYRS1j8'

修改单个候选人curl如下

curl --silent --location --request POST 'http://api-platform.staging-8.svc.k8s.staging.mokahr.com:8080/api-platform/v1/candidate/customField/update' \
--header 'authCode: DMyoCupHTMKmYQ4QANQVxe7AWEkscMTj' \
--header 'Authorization: Basic dGVzdDE6' \
--header 'Content-Type: application/json' \
--data-raw '{
    "updateCustomFieldsReqDTOList": [
        {
            "candidateId": 201203910,
            "orgId": "livingsimple",
            "operatorEmail": "[email protected]",
            "hireMode": 1,
            "customIdAndDetailDTOList": [
                {
                    "id": 270,
                    "detail": {"startDate":"2011-09 00:00:00","endDate":"2015-08 00:00:00"},
                    "type": "date_group_info"
                }
            ]
        },
    ]
}'

postman参数化批量生成候选人步骤

1、postman编写Pre-request Script,脚本。批量生成body内容实现一个body体内传入多个候选人功能

 

代码如下

var number=10;    --设置变量来控制 每次请求传入的候选人数量
var orgId="livingsimple";
var operatorEmail="[email protected]";
var Clist = [201213489,201213488,201213487,201213486,201213485,201213484,201213483];  --通过数据库查询出可修改的候选人ID


function add(count){
var str1 = new Array(count);
for (i = 0; i < count; i++) {
var str2 = {};
str2["candidateId"]=Clist[i];
str2["hireMode"]=1;
str2["orgId"]=orgId;
str2["operatorEmail"]=operatorEmail;
var customIdAndDetailDTOList=[{
"id": 263,
"detail": "单行文本修改300",
"type": "string_info"
}];
str2["customIdAndDetailDTOList"]=customIdAndDetailDTOList;
str1[i]=str2;
}
console.info(str1);
pm.globals.set("body", JSON.stringify(str1));
}
add(number);

2、body参数如下

版权声明
本文为[学海无涯乐做舟]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_41918841/article/details/124319252