Download student submitted files per assignment via the API?

183 views
Skip to first unread message

Ryan Sargent

unread,
Jan 9, 2016, 12:50:28 PM1/9/16
to Canvas LMS API Users
Hey, perhaps I'm horribly misreading the submission API, but I can't figure out how to download any submitted files for a given student for a given assignment. 

Is this supported by the API? I only see documentation on file submission, rather than retrieval. 

Thanks for any insight!

-Ryan

Battis, Seth

unread,
Jan 11, 2016, 8:37:52 AM1/11/16
to canvas-lms...@googlegroups.com
Ryan --

Looks to me like when you query for an individual submission, the response includes an attachments array, which includes, for each attached file, a download URL. You don't need an API token to download from that URL either -- it includes a verifier code, so you can hoover up the URL through whatever your favored web file pipeline of choice might be.

I would not say that you misread the API, btw. I would say the API fails to mention this.


— S

Mathematics Dept. Chair • Director of Academic Technology • FIRST Team Mentor
St. Mark's School • 25 Marlboro Rd., Southborough, MA 01772 • stmarksschool.org

--
You received this message because you are subscribed to the Google Groups "Canvas LMS API Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-api-u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ryan Sargent

unread,
Jan 19, 2016, 9:08:53 PM1/19/16
to Canvas LMS API Users
Thanks for the response, but I'm still missing something. 

Is this attachments array in the response object? All I'm seeing is the following response object from the endpoint: https://canvas.instructure.com/api/v1/courses/:courseid/assignments/:assignmentid/submissions/:userid
{
        "id": XXXXXXXX,
        "body": null,
        "url": null,
        "grade": null,
        "score": null,
        "submitted_at": "2016-01-19T16:43:04Z",
        "assignment_id": 2000000XXX1428,
        "user_id": 20000000XXX668,
        "submission_type": "online_upload",
        "workflow_state": "submitted",
        "grade_matches_current_submission": true,
        "graded_at": null,
        "grader_id": null,
        "attempt": 1,
        "excused": null,
        "late": false,
    }

or do I look elsewhere to find where attachments array can be used? 
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-api-users+unsub...@googlegroups.com.

Battis, Seth

unread,
Jan 20, 2016, 8:24:26 AM1/20/16
to canvas-lms...@googlegroups.com
Hmm. Are you testing this on a submission that has an uploaded file?

I just tried this out on my test instance:

GET

https://stmarksschool.test.instructure.com:443/api/v1/courses/:courseid/assignments/:assignmentid/submissions/:userid

And received the following response (suitably anonymized):

{
  "id": 730051,
  "body": null,
  "url": null,
  "grade": "8",
  "score": 8,
  "submitted_at": "2016-01-06T14:56:58Z",
  "assignment_id": :assignmentid,
  "user_id": :userid,
  "submission_type": "online_upload",
  "workflow_state": "submitted",
  "grade_matches_current_submission": false,
  "graded_at": "2016-01-03T20:20:05Z",
  "grader_id": 1,
  "attempt": 7,
  "excused": null,
  "late": false,
  "preview_url": "https://stmarksschool.test.instructure.com/courses/:courseid/assignments/:assignmentid/submissions/:userid?preview=1&version=7",
  "attachments": [
    {
      "id": 172839,
      "folder_id": 3440,
      "display_name": "implements bullet and collision FD.pdf",
      "filename": "implements+bullet+and+collision+FD.pdf",
      "content-type": "application/pdf",
      "url": "https://stmarksschool.test.instructure.com/files/172839/download?download_frd=1&verifier=:verificationcode",
      "size": 331034,
      "created_at": "2016-01-06T14:56:57Z",
      "updated_at": "2016-01-06T14:56:58Z",
      "unlock_at": null,
      "locked": false,
      "hidden": false,
      "lock_at": null,
      "hidden_for_user": false,
      "thumbnail_url": null,
      "modified_at": "2016-01-06T14:56:57Z",
      "locked_for_user": false,
      "preview_url": "/api/v1/canvadoc_session?blob=%7B%22user_id%22:11060000000000001,%22attachment_id%22:172839,%22type%22:%22canvadoc%22%7D&hmac=bacdccd15da12a73ff48076194efc08e3f8257a6"
    }
  ]
}



— S

Mathematics Dept. Chair • Director of Academic Technology • FIRST Team Mentor
St. Mark's School • 25 Marlboro Rd., Southborough, MA 01772 • stmarksschool.org

To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-api-u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

 

--
You received this message because you are subscribed to the Google Groups "Canvas LMS API Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-api-u...@googlegroups.com.

Ryan Sargent

unread,
Jan 20, 2016, 3:34:45 PM1/20/16
to Canvas LMS API Users
That is fascinating. No, I'm quite sure the student I'm testing on has a submission for the assignment. I'm definitely not getting that last field. 

So! I know that my role in this course is Teacher, and if I'm seeing ANY submission information, my token should reflect that. Perhaps I need to use the subdomain of utah.instructure as you have done with stmarkschool.test.instructure? Or perhaps the .test portion of the URL is what is giving you more response fields? 

Is their a direct way to talk to Instructure to badger them about API permissions? 

Thanks again for sticking with this,
Ryan
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-api-users+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Canvas LMS API Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-api-users+unsub...@googlegroups.com.

Ryan Sargent

unread,
Jan 20, 2016, 8:11:30 PM1/20/16
to Canvas LMS API Users
Using canvas.instructure.com/api/... was my issue. When I replaced it with "utah.canvas.etc" then I saw the fabled assignments field. 

I cannot tell you how happy I am to see this. Thank you. 
...
Reply all
Reply to author
Forward
0 new messages