0

这是我在 Postman 中的预请求脚本:

var requestToRun;

switch (data["Condition"]) {
    case (1):
        requestToRun = [{ 
            "test": "yusuf-klmn",
            "imageUrl": "",
            "name":"lop-kjm",
            "test2": "yusufplm",
            "type": "Product",
            "category": "string",
            "price": 0,  "salePrice": 0,
            "currency": "TRY",
            "taxRatio": 0,
            "salesUrl": ""
        }]
        break;
    case (2):
        requestToRun = [{ 
            "test": "yusuf-klmn", 
            "imageUrl": "",
            "name":"lop-kjm" ,
            "test2": "yusufplm",
            "type": "Product",
            "category": "string",
            "price": 0, 
            "salePrice": 0, 
            "currency": "TRY",
            "taxRatio": 0,
            "salesUrl": ""
        }]
        break;
}
 
pm.globals.set('req_body', JSON.stringify(requestToRun));
postman.setNextRequest(requestToRun);
console.log(requestToRun)

这是我的请求正文内容:(在这里调用 req_body 作为 Json 正文内容)

{{req_body}}
4

0 回答 0