I have created a collection with 4 APIs. That collection is being used for monitoring purposes.
Due to certain scheduled tasks between 3 am to 4 am EST, the API calls timeout. I tried using pre-script to skip request during the above mentioned timeframe. The pre-scripts work fine when I execute it manually but monitor executes the APIs and doesn’t skip. It seems like pre-scripts are not being executed at all.
// Example pre-request script to skip requests during maintenance window (3 to 4)
const now = new Date();
var easternTime = now.toLocaleString("en-US", {hour: '2-digit', hour12: false, timeZone: "America/New_York"});
// Skip the request if the current time is between 3 to 4 (maintenance window)
if (easternTime === 3 || easternTime === 4 ) {
console.log("Skipping request during maintenance window (3 to 4)");
pm.execution.skipRequest() // Skip this request
}
Can someone please help me achieve skipping requests between 3 to 4?