Using canvas API to access files and modules as a student
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am a student working on a project that hopes to integrate Canva's API to make some tool for progress tracking in all courses. The problem I am running into at the moment is with viewing files and modules as a student. When I send a request I get the 401 code back which means I am not authorized. I was wondering why this would be the case as on my course websites I am able to see files and modules. My initial guess is that the response of that request would list all the files both published and unpublished and I am assuming that its the same for modules.
My question is; using the API is there a way I can get a list of published files and modules?
Let me be more specific. I am using Postman to query the API and yes I have gotten my bearer token and I am authorizing API access using the bearer token. In terms of API requests that I have gotten to work, I have gotten a list of all my courses using the GET api/v1/courses endpoint, my enrollments by using the GET api/v1/users/:user_id/enrollments and my user info with the endpoint that you specified earlier.
The issue comes from when I try to perform a GET api/v1/courses/:course_id/files or a GET /api/v1/courses/:course_id/modules. The resulting message is as follows:
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
xxx was just a placeholder. It can be any length.
When I tried the course enrollments as a student who was not in the course, I got a 403 error with the error message you gave. You said you got a 401 error -- was that a typo?
There is a difference. 401 means the credentials were not correct. 403 means the server understood the request but you do not have permissions to access it.
Are we positive that the course in question is published and that you can visit it within Canvas?
Here's another trick/check. Log into Canvas (web interface) and go to the course you're having problems with. Add /api/v1 at the beginning of the path (after the hostname) and then /files or /modules to the end of the path. It should look like <instance>/api/v1/courses/xxx/files or <instance>/api/v1/courses/xxx/modules. Then hit enter. If it works there but not through the API, then it's likely an authentication error. If it doesn't work there, it's something to do with the course.
Can you get /files or /modules for any course or is it just one throwing the issue? If just one, then it's something about that course -- such as being unpublished.