Since the API call will be in an automated extract, is there a way to write the syntax with relative dates, such as last 90 days relative to the day the API call is made?

Created by Atif Ikramuddin, Modified on Tue, 26 Aug at 7:24 PM by Atif Ikramuddin

  • Yes, we can dynamically generate relative dates (e.g., “last 90 days”) in automated API calls using scripting tools like Postman. This eliminates the need to manually update the last_modified_date parameter with each request.

  • Automated Date Calculation via Postman

To achieve this, you can calculate the date 90 days ago within your automation script (e.g., in Postman) and pass it as a query parameter.

  • Steps to Implement:
  • In Postman, go to the Pre-request Script tab and add the following code:

let now = new Date();

let ninetyDaysAgo = new Date(now.setDate(now.getDate() - 90));

let formattedDate = ninetyDaysAgo.toISOString().split('.')[0] + 'Z'; -- removes milliseconds

pm.environment.set("ninetyDaysAgo", formattedDate);

 

  • In the request URL, use the variable:

https://api.resilinc.com/v1/event_details?last_modified_date=gte:{{ninetyDaysAgo}}&limit=1000&offset=0

  • Ensure that the active environment in Postman includes the {{ninetyDaysAgo}} variable. Postman will set this automatically if the script above is in place.

Please note: The Resilinc API may have difficulty parsing the gte: syntax as a filter. While the example above shows how it might be implemented, behavior could vary across environments.

 

  • Alternate Filter Syntax (Try These Variants)

         If gte: does not work, the API may require one of the following formats instead:

  • ?last_modified_date[gte]=2025-03-01T00:00:00Z
  • ?filter=last_modified_date>=2025-03-01T00:00:00Z
  • ?last_modified_date=gte.2025-03-01T00:00:00Z

 

After retrieving the initial 90-day dataset, we recommend switching to daily extraction. For this, set last_modified_date to the most recently completed day. This helps ensure you're always getting newly added or updated records with minimal redundancy.

Note: This functionality shown above may or may not work at your end, depending on how your environment handles dynamic or scripted query parameters.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article