Date range format for API

rest-api

(AJ) #1

When I call List Incidents Rest Endpoint, it returns incidents when date_range is set to all.
But when I tray to use a specific date range, it fails.

What is the correct format for date to be supplied?

WORKS:
https://api.pagerduty.com/incidents?date_range=all&statuses%5B%5D=triggered&statuses%5B%5D=acknowledged&statuses%5B%5D=resolved&urgencies%5B%5D=high&urgencies%5B%5D=low&time_zone=UTC

FAIL:
https://api.pagerduty.com/incidents?since=2015-11-10T01%3A02%3A52Z&until=2016-11-10T01%3A02%3A52Z&statuses%5B%5D=triggered&statuses%5B%5D=acknowledged&statuses%5B%5D=resolved&urgencies%5B%5D=high&urgencies%5B%5D=low&time_zone=UTC

FAIL:
https://api.pagerduty.com/incidents?since=2015-11-10&until=2016-11-10&statuses%5B%5D=triggered&statuses%5B%5D=acknowledged&statuses%5B%5D=resolved&urgencies%5B%5D=high&urgencies%5B%5D=low&time_zone=UTC

Error returned for failed ones are:
{
“error”: {
“message”: “Invalid Input Provided”,
“code”: 2001,
“errors”: [
" is invalid."
]
}
}


(Malcolm Konner) #2

Hi Anup,

Date and time format for our REST API calls are required to be in the ISO 8601 date/time format which I have included a reference to in our dev docs here:

https://v2.developer.pagerduty.com/docs/types#datetime

I replied in your support ticket too but it looks like the issue with the failed calls that your shared is the result of the span of time in your time parameters being greater than 6 months. This endpoint can only query up to 6 months at a time, so if you need to get incidents over a longer time period than that, I would recommend breaking up the request into smaller chunks.

Please let us know if you have any further questions!

Thank you,
Malcolm


(AJ) #3

Perfect. Actually it seems to be 5 months. It worked when I tried 2016-01-01 to 2016-05-31. But it fails when the end date is beyond that. I have updated my code to run it with a 5 month date range. Thanks.