2

I am using Okta for SSO. I want to list all Okta users, but the API has a max limit of 200. So I need to use pagination here.

Initial I used the URL

{{url}}/api/v1/users?limit=200

Not I got the response with the first 200 users, and a next link in the response header. The next link was like

{{url}}/api/v1/users?after=1uid&limit=200

Please have a look at the above after value. Character 1 got prepended to the last user ID. Why is that?

Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
Raghaven 3534
  • 286
  • 1
  • 5
  • 10

1 Answers1

4

The after parameter value is a cursor, not a user ID. From the Okta API docs,

Pagination is based on a cursor and not on page number. The cursor is opaque to the client and specified in either the before or after query parameter.

Your value looks like a user ID, but the cursor structure could change in the future. The proper way to handle the cursor is to simply follow the next link in the response header. Your code shouldn't need to try to parse or understand the contents of the next link.

Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
  • 2
    To be a little clearer. there is a header in the response called 'Link', that will have the url to the next page of results. (Be careful there are actually two Link headers, one for the link you just used and one for the next page) – fei0x Sep 25 '18 at 17:48