0

This my Pre-request script in 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)

This my Request Body content:(calling req_body here as a Json body content)

{{req_body}}
Youssef Bouhjira
  • 1,599
  • 2
  • 22
  • 38

0 Answers0