I use Canvas api to access the submissions information, what I am trying to do is to download the submission of student's assignments. I use this format:
This can find individual submission but not include download url. I want to know how to get the exact download url because when I grab url from web and use it in other place, it redirects me to the login page.
Solved! Go to Solution.
Hello, @gchen13 ! Because of the highly technical nature of this question, I'm sharing it with the Canvas Developers and Canvas Admins group to bring some experts to the discussion. Also, please note that this question is very similar to one posted earlier today--How to download all students submissions with url --and we try to keep responses unified in a single thread, so I'm going to request that responses be posted here, and I've posted a link to this question in the other thread.
For quick reference, here's the text of the other question posted earlier today by @shu14 (both Shengjie Hu and Jason C are with Stevens Institute of Technology):
I want to download the zip file of all students' assignment submissions. From the API, we get the follow data. But this url is not to a file ("submissions_download_url":"https://[domain]/courses/:coursesID/assignments/:assignmentsID/submissions?zip=1"). When I try to open this page, my API token becomes useless.
So my question is: Who works out that how to download the zip file of all students' assignment submissions. What I should to do?
I am using C++. Thank you.
You should see a url that is the downloadable file. Have you used Postman to make the call? I highly recommend it.
Yes, I use it to make the call, but only find the preview url. The real address seems to be hidden.
In your example the student didn't submit an assignment but was given a grade in the gradebook, so no submission can be downloaded. If the student had a submission there would be an attachments list below the preview_url field, that is where you will find the url to download the assignment, it will have a verifier code in the URL which will allow scripts to download the assignment. Here is an example:
"display_name": "Math Application 1 preflight.pdf",
Thanks for your reply.
I reviewed the assignment from Canvas and found there was an address, submission could be downloaded from it via browser, but this address requires login info and I am not allowed to call it from postman. Also, I still found nothing below the preview address even though student had uploaded file during submission.
If the student has submitted a document, you should see the "attatchments" array in the json object.
I have tested this in my environment, and verified that the download URL works.
If you are not getting the "attachments" array, verify your parameters to confirm the assignment you are focused on.
Jason C The URL preview will appear on every submission returned even if the student did not submit an assignment. The preview URL refers to the SpeedGrader in the Canvas UI where the teacher can grade, view, comment on, and even download the assignment. In cases where there is no submission it does seem misleading to have the preview URL still included in the submission response, but it allows the teacher and student to comment back and forth even if they have not submitted the assignment.
In most cases, the preview URL is useful for apps that run in the browser where you may already have logged into Canvas and then the Preview URL would work because it uses the session already in use or if it is an LTI app you have already authorized it to act and log in as you. It doesn't work well in cases where a script is trying to download a submitted assignment and that is where the assignment list is useful because those will allow you to directly download the files without logging in.