cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mikael_fridenfa
Community Member

How to extract a download file-id for a selected submission using the API

Jump to solution

Hello,

By the Python canvasapi and the command todo_items = canvas.get_todo_items(), I am in some initial experiments able to find the web address of each ToDo speedgrading page, thus covering all student submissions that need to be graded. When such a page is opened, I only need to click on a file download symbol to download the selected student submission file. 

But how is this link (for download itself) obtained, if I wish to automate the whole process (and not to use for instance a web driver to click on this link)? The link I am looking for should have the format:

https://[...].com/courses/#1/assignments/#2/submissions/#3?download=#4

Where [...] is the web domain and #1 to #3 known integers (by extraction of information from todo_items). In other words, what I am looking for is the integer #4, which is some kind of a download id that I cannot find any specification for how to extract, not even when I analyze the source code of each speedgrader page. However, when I insert the link above, download of the selected file is automatically invoked.

Is it possible to extract this integer?

Thanks

Mike

0 Kudos
1 Solution

Accepted Solutions
pklove
Community Champion

If you are using the API and know #1 to #3, then you just need to call the submissions endpoint to get the submission details:

   .../api/v1/courses/#1/assignments/#2/submissions/#3

The returned json will have an attachments array.  Each entry will have the id (#4) and a variety of other information, including a download url looking something like: https://....//files/123/download?download_frd=1&verifier=somerandomstring

View solution in original post

2 Replies
pklove
Community Champion

If you are using the API and know #1 to #3, then you just need to call the submissions endpoint to get the submission details:

   .../api/v1/courses/#1/assignments/#2/submissions/#3

The returned json will have an attachments array.  Each entry will have the id (#4) and a variety of other information, including a download url looking something like: https://....//files/123/download?download_frd=1&verifier=somerandomstring

View solution in original post

mikael_fridenfa
Community Member

Thanks Peter!

That worked perfectly! 🙂

Best

Mike