Hi @ColinOBrien,

What scripting language are you using?  Someone here could probably share some working code for pagination to help you out if we knew what language you were working in.

Your general approach seems correct, so I'll throw out a couple details that could be impacting what you're doing.  First, when you're using the pagination next links, you don't need to include any additional parameters as JSON, form data, etc, as the next link will have all of your parameters URL-encoded as part of the link.  Second, when you're parsing for the next link, make sure you're getting the whole thing including the entire querystring, as that is where all your parameters and the pagination info is included.

For debugging purposes, you could probably print the next url your script is generating and examine it to make sure the format looks correct (for this specific API, you should see at least your start_time, end_time, page paramaters in the querystring, and the base API url should stay the same).  As an example, you should see something like this progression:

First call url:
https://institution.instructure.com/api/v1/users/zzzzz/page_views?end_time=2025-03-22T03:59:59Z&start_time=2025-03-21T04:00:00Z&per_page=100 

Next call url:
https://institution.instructure.com/api/v1/users/zzzzz/page_views?end_time=2025-03-22T03%3A59%3A59Z&start_time=2025-03-21T04%3A00%3A00Z&page=bookmark:bunchofrandomcharactershere&per_page=100 

Next call url:
https://institution.instructure.com/api/v1/users/zzzzz/page_views?end_time=2025-03-22T03%3A59%3A59Z&start_time=2025-03-21T04%3A00%3A00Z&page=bookmark:bunchofdifferentrandomcharactershere&per_page=100  

Now as I was investigating the flow of this exact API call in my working scripts to create this post, I noticed a bit of an anomaly.  Fro some reason, Canvas appears to be repeating the start_time and end_time parameters for the next link, so you actually end up with:

Next call url:
https://institution.instructure.com/api/v1/users/zzzzz/page_views?end_time=2025-03-22T03%3A59%3A59Z&start_time=2025-03-21T04%3A00%3A00Z&end_time=2025-03-22T03%3A59%3A59Z&start_time=2025-03-21T04%3A00%3A00Z&page=bookmark:bunchofrandomcharactershere&per_page=100  

That repetition hasn't affected the function I created to get all pages of a Canvas API result, but I thought it was interesting because I don't think the parameters really *should* be getting repeated in the URL. Depending on your exact code, maybe it's throwing something off though.

Let us know if you're able to share your programming language or any of your existing code at all.

-Chris 

View solution in original post

Who Me Too'd this solution