vendredi 30 octobre 2020

Postman test script:Setting variables for Basic auth and setting a field in the next request based on the username password combination

1.In the first request I am generating token using basic Auth 2. In the next request, using the generated token ,I am sending a request payload where I want to set like if the username, password combination (in the first request) is suppose a and b, then I want my tradingAgent field to be suppose B, else C or other combinations How can I achieve this, I am new to postman and javascripting.

My second request looks like this

"sequence": "5533", "tradingAgent": "",

I understand in the pre-requisite script I have to write..but the below doesnt work..enter image description here var username = pm.environment.get("username"); if (username = ("a")) (password = ("b")) pm.environment.set("tradingAgent","B"); else pm.environment.set("tradingAgent","C");

Aucun commentaire:

Enregistrer un commentaire