I have a question in regard to Okta paging. We want to implement a custom paging solution in Java using page and page size. Has anyone implemented something similiar and if so how have you done it? When we do a query with limit we get a next link:
From what I understand the after contains a cursor to the next page of data. What if I want to ask for page 5 with a size of 10. Is there a way to accomplish that? Also does this cursor expire? If so how long does the cursor last for? I.E. what is the precise expiration time? Is there way I can query and just get the cursors(I.E. just cursors and not pull all of the data)?
Any help you can please give would be greatly appreciated. Thank you.
Also, importantly: you must use the Link headers in the response to page around.
You use the limit query parameter to specify the page size (default is 100, max is 200).
So, you could use /api/v1/users?limit=50 to get back the first page. In the response, you would inspect the Link headers to get the link for the next page of data.
Thank you for the information. Do link headers or links in the response expire. I.E. is there a time limit to when they can be used in a call. For instance If I receive a Next Link like:
and I use the link http://localhost:8080/users?after=200uh8ttBixyDwxA2g0h8&limit=14 to get the next page can I use this link at any time or will it expire at some point? If it will expire when will that be I.E. in an hour, two hours, a day, a week? Is there a setting in Okta for this expiration? Please let me know the answer to these questions. Thank you.
I had hard time figuring out this pagination thing, so thought of contributing to this page so it helps others!!.
My requirement was to search users with a specific search query like below
I get the results in the postman body. How do I know if I got all the users with that specific search criteria? Well you have to take a look at the response headers. If you see only one link header as “self” then thats the end of the page. There are no more records in that Okta API.
If there are more pages (more records), you will see two link headers
rel=“self”
rel=“next”
Also notice “after” in the second (next) link header (below screen shot). That is what you have to follow in the next API query until you reach the end of the page, i,e until there is no more rel=“next” in the response headers!!!