I have been playing around with the "List user page views" API endpoint and pagination appears to be broken...or I'm an idiot. Either possibility is equally likely.
Normally, when you go and get a page of data you will get a "next" in the header as explained here:
Pagination - Canvas LMS REST API Documentation
I've written lots of API calls and this always works fine. HOWEVER, when I try to bring back page views it *ALWAYS* shows that there is a "next" page even when there is not. Obviously this is a problem because my code keeps going back for more data.
I would love some feedback. I'm hoping I'm just missing something, but I'm afraid that this API endpoint just does not work like all of the others I've used.
It does work slightly differently. The paging links have page=bookmark:sadfsdfd rather than the usual page=number.
There are some other endpoints like this. I first came across this in this post: https://community.canvaslms.com/message/61158-re-students-login-logs-download?commentID=61158#commen...
I haven't actually tried endpoints like this, so a few questions. What happens when you get to the end of the data? Do you get an empty return, or just a repeat of the last lot of data you got? Does the bookmark change? If not you could check to see if the next bookmark matches the current one.
It just keeps returning the same data. In fact, I tried to bring back page=2 of data and it brings back the same data as page=1. But as you said, I guess it doesn't use the same page=number format.
I'm not familiar with what you mean when you say "page=bookmark:sadfsdfd". Where is this sort of pagination documented? I've only used the "page=number".
I just tried List user page views and on the last page the next page dropped off like usual and a last link appeared (which equalled the current link, so all good there).
So it worked like usual for the user I tried.
I think that is getting stripped out. I never actually see anything in link other than something like this:
"Link": "; rel=\"current\",; rel=\"next\",; rel=\"first\"",
So I always just look to see if there is a "next" and if there is I go back for the next page.
BTW, page=number isn't documented either. The link urls are opaque, so the intention is that they are used as returned. So, although you can usually make up your own one with page=number, there is nothing to say you can do this.
Hmmm. See, I'm parsing out the header manually. I'm not using any libraries. I flat out do not see the URLs in the header text. How do you actually see/use "opaque" URLs like this?
I'm using PHP, but that was actually copied/pasted from the live API tool that Instructure provides. But I never see the URLs in the header text that comes back to my PHP scripts.