- 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:
- 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
- Manual Workaround
- If automated filtering is not working as expected, you can manually enter a static date representing 90 days ago (e.g., 2025-03-01) as shown below:
- https://api.resilinc.com/v1/event_details?last_modified_date=gte.2025-03-01T00:00:00Z&limit=1000&offset=0
- To retrieve large datasets, ensure you increment the offset value in each subsequent request (e.g., offset=0, offset=1000, offset=2000, etc.).
- Recommended Practice for Ongoing Data Extraction:
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
Feedback sent
We appreciate your effort and will try to fix the article