0

I'm building an application which pulls down incident listings for my org via Pagerduty's REST API.

The GET /incidents endpoint does respond with more, offset, and other keys that are indicative of pagination being supported, and it does make intuitive sense on this endpoint, but I haven't been able to actually paginate these results:

  • Passing offset or limit as a query param returns a 403
  • Passing these in various forms in request headers just gets ignored entirely

Is there a way to paginate these results at all?

verandaguy
  • 210
  • 2
  • 7

2 Answers2

0

it might help to include the code you're using to make the request, or a curl request from the command line. Including pagination parameters shouldn't lead to a 403, so I'm thinking something else might be missing.

You should be able to paginate the lists using GET parameters, e.g

https://api.pagerduty.com/incidents?limit=20&offset=100

limit has a maximum value of 100, and limit + offset together must be less than 10,000. That might be why you were getting an error?

See here for additional details on the pagination parameters

Hannele
  • 9,301
  • 6
  • 48
  • 68
  • I was using `limit` and `offset` with much smaller values, but at this point I'm not using the Pagerduty API for this task -- it was too much trouble to stand a script up with these issues. – verandaguy Apr 14 '20 at 22:19
  • 1
    I'm suspecting you were running into some other kind of issue if you were getting a 403. – Hannele Apr 17 '20 at 21:54
0

Yes, it's possible to paginate the results.

After invoking the API method for the first time, you need to check the more response field value. If true, then you can call the API method again with an updated offset.

offset is related to the total results, and not the total pages.

The 403 error code response you're getting is most likely related to the user permissions and not with paginating results.

famen
  • 55
  • 1
  • 5