![]() ![]() In postman use tab Tests to create a loop logic. Pm.t("TransactionIds", JSON.stringify(ids)) - we are setting up a new collection of variables that now does not include the id that was handled. tEnvironmentVariable("transactionId", id) - change transaction id from query param to actual transaction id Ids.shift() - we use it to remove id that we will use from our ids list (to prevent running twice on the same id) Pm.collectionVariables.get - gets array of transaction ids from collection variables. ![]() Pm.t("TransactionIds", JSON.stringify(ids)) tEnvironmentVariable("transactionId", id) ![]() let ids = pm.collectionVariables.get("TransactionIds") In postman use tab Pre-request Script to change transactionId variable from query param to actual transaction id. For demonstration purpose I will use "Transactions Request" name. Save request to collection (Save button in the right corner).If you need a token for request you should add it here, in Authorization tab.If (( != "SUCCESS" & = 0) & (pm.environment.get("tries") < maxNumberOfTries)) variable for changing it from pre-request script. The code I'd end up if I were you is: const maxNumberOfTries = 3 // your max number of triesĬonst sleepBetweenTries = 5000 // your interval between attempts I found an awesome post about retrying a failed request by Christian Baumann which allowed me to find a suitable approach to the exact same problem of first polling the status of some operation and only when it's complete run the actual tests. ![]()
0 Comments
Leave a Reply. |