API response for Account's active Courses doesn't include last page's Link header

Community Member

Hi there! I'm using the Canvas REST API to fetch an Account's active Courses list, but I've noticed that its response's behavior has slightly changed. I've been hitting the /api/v1/accounts/:account_id/courses endpoint (which is documented at https://canvas.instructure.com/doc/api/accounts.html#method.accounts.courses_api), with a GET request. I'm also providing ?include[]=term&page=1&per_page=4 as query string, to ensure I'm getting the first page, with no more than 4 results.

The request succeeds but, inspecting the response's headers, I found out that it has no "last"-labeled Link header anymore; such header is intended to denote the last page's URL. This are the Link headers I'm getting (just current, next and first page):

<https://redshelf.instructure.com/api/v1/accounts/self/courses?include%5B%5D=term&page=1&per_page=4>; rel="current"
<https://redshelf.instructure.com/api/v1/accounts/self/courses?include%5B%5D=term&page=2&per_page=4>; rel="next"
<https://redshelf.instructure.com/api/v1/accounts/self/courses?include%5B%5D=term&page=1&per_page=4>; rel="first


Digging a little bit into Canvas' canvas-lms repository at GitHub, particularly at the /account API namespace's controller, I came across this line https://github.com/instructure/canvas-lms/blob/e6540ff0f68f17991c004f4ab2dcb056b962e241/app/controll.... It seems that the Account model has a allow_last_page_on_account_courses property. Furthermore, I looked at the repo's latest commits, and I found this two:

So it seems that this allow_last_page_on_account_courses setting, introduced very recently, defaults to be disabled and, apparently, determines if this last-page Link header is sent for this response or not. I tried enabling it at the Account through Instructure's UI, but I had no luck; I even tried both fetching and tweaking it via the API (GET request to /api/v1/accounts/:acount_id/settings/, and PUT request to  api/v1/accounts/self with a body like

"account": {
"allow_last_page_on_course_users": true


, respectively), but had no luck as well.

Does anybody know if this allow_last_page_on_account_courses setting could be the culprit for the missing last-page Link header? Or if there's any way to effectively toggle it to enabled? Thanks!

Best regards.