{"info":{"_postman_id":"a4094aa5-a6d0-41aa-803a-a8065ae06b6d","name":"Time loop","description":"<html><head></head><body><p>This Collection defines a starting time stamp, then loops through a request posting 1 minute increases to the starting time for 70 iterations.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"5293839","collectionId":"a4094aa5-a6d0-41aa-803a-a8065ae06b6d","publishedId":"SWTK4EWu","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"publishDate":"2020-02-11T00:12:36.000Z"},"item":[{"name":"POST Time","event":[{"listen":"prerequest","script":{"id":"31ba82d7-d836-47e4-92d4-c17dfed7e2b7","exec":["const moment = require('moment');","","// if there is no starting time stamp set....","if (!pm.variables.has('starting_time_stamp'))","{","    // declare a new time 10 minutes before now, and store it in the environment.","    let startingTimestamp = moment().subtract(10,'minutes');","    pm.variables.set('starting_time_stamp',startingTimestamp);","}","// if there is no counter started, declare one as a local variable","if (!pm.variables.has('counter'))","{","    pm.variables.set('counter',0);","}","","// get the current counter value","let counter = pm.variables.get('counter');","console.log('Counter: ' + counter)","","// create a timestamp by pulling in the starting time stamp value, and adding minutes to it based on the counter value","let timestamp = moment(pm.variables.get('starting_time_stamp')).add(counter,'minutes').toISOString();","console.log('Timestamp: ' + timestamp)","","// set a local variable, 'time', with the modified timestamp value for this iteration","pm.variables.set('time',timestamp);","","// incremement the counter by 1 and store in the local variable","counter++;","pm.variables.set('counter',counter);"],"type":"text/javascript"}},{"listen":"test","script":{"id":"2accf603-367a-454f-9a53-5c833cf9ff8a","exec":["// get current counter value","let counter = pm.variables.get('counter');","","// if the the counter is less than 71 (70 iterations)....","if (counter < 71)","{","    //loop through this request again","    postman.setNextRequest(pm.info.requestName);","}"],"type":"text/javascript"}}],"id":"6989501f-9a43-4726-9b2f-16ebc472c569","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"timestamp\": \"{{time}}\"\n}"},"url":"https://postman-echo.com/post","description":"<p>How this request works:</p>\n<p><strong>Pre-request script</strong></p>\n<ul>\n<li>Sets a starting timestamp (now, minus 10 minutes)</li>\n<li>Initialize a loop counter</li>\n<li>Sets the timestamp of the current loop based on loop counter, and sets a variable used in the request body</li>\n<li>Increments the counter</li>\n</ul>\n<p><strong>Test script</strong></p>\n<ul>\n<li>Check the loop counter, and loop the current request if counter &lt; 71 (70 iterations)</li>\n</ul>\n","urlObject":{"protocol":"https","path":["post"],"host":["postman-echo","com"],"query":[],"variable":[]}},"response":[],"_postman_id":"6989501f-9a43-4726-9b2f-16ebc472c569"}],"event":[{"listen":"prerequest","script":{"id":"6627fa3a-86a0-4f6b-bacc-3d39f13c71c5","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"ec7e5694-726b-41cf-994e-a1e4af29c5e4","type":"text/javascript","exec":[""]}}]}