Register for InstructureCon25 • Passes include access to all sessions, the expo hall, entertainment and networking events, meals, and extraterrestrial encounters.
Found this content helpful? Log in or sign up to leave a like!
I'm trying to download the actual file the students upload via the API. I have a list of all the submissions I want to download using the URL
urlAPI_root = url_root+'/api/v1/courses/' + str(assignment.crsID) + '/assignments/' + str(assignment.id) + '/submissions/'+str(submission['user_id'])
I receive the information I need to know about the grade, time submitted and such. However, it informs me that the submission_type is online_upload but I cannot access the file that was uploaded. Any ideas?
Solved! Go to Solution.
@wade_ashby you can get a list of all submissions for an assignment using this API call:
Submissions - List Assignment Submissions
This API call will return a json list of submission objects:
Submissions - Submission Object
Here's an example of the syntax:
http://mysite.instructure.com/api/v1/courses/1234/assignments/1234/submissions
Within each submission object that contains an uploaded document, you will see an "attachments" object.
One of the parameters of the "attatchment" is: "url"
This is the URL for the document attached to the submission.
You are able to download the file from this URL.
Here is an example of one of the submission objects that is returned from a test course that I work with, I have highlighted the URL variable in bold text:
{
"id": 546,
"body": null,
"url": null,
"grade": "21",
"score": 21,
"submitted_at": "2015-07-23T16:12:22Z",
"assignment_id": 1234,
"user_id": 1234,
"submission_type": "online_upload",
"workflow_state": "graded",
"grade_matches_current_submission": true,
"graded_at": "2015-11-12T20:22:50Z",
"grader_id": 1234,
"attempt": 1,
"excused": null,
"late": false,
"preview_url": "https://mysite.instructure.com/courses/1234/assignments/1234/submissions/1234?preview=1&version=1",
"attachments": [
{
"id": 5029,
"folder_id": 1234,
"display_name": "mysampledoc.docx",
"filename": "mysampledoc.docx",
"content-type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"size": 15081,
"created_at": "2015-07-23T16:12:21Z",
"updated_at": "2015-07-23T16:12:23Z",
"unlock_at": null,
"locked": false,
"hidden": false,
"lock_at": null,
"hidden_for_user": false,
"thumbnail_url": null,
"modified_at": "2015-07-23T16:12:21Z",
"locked_for_user": false,
"preview_url": "/api/v1/canvadoc_session?blob=%7B%22user_id%22:61240000000000033,%22attachment_id%22:5029,%22type%22:%22canvadoc%22%7D&hmac=0b1bcf1a12345fdaec654321d1e48c0bfc6b1167"
}
]
}
I hope this helps.
@wade_ashby you can get a list of all submissions for an assignment using this API call:
Submissions - List Assignment Submissions
This API call will return a json list of submission objects:
Submissions - Submission Object
Here's an example of the syntax:
http://mysite.instructure.com/api/v1/courses/1234/assignments/1234/submissions
Within each submission object that contains an uploaded document, you will see an "attachments" object.
One of the parameters of the "attatchment" is: "url"
This is the URL for the document attached to the submission.
You are able to download the file from this URL.
Here is an example of one of the submission objects that is returned from a test course that I work with, I have highlighted the URL variable in bold text:
{
"id": 546,
"body": null,
"url": null,
"grade": "21",
"score": 21,
"submitted_at": "2015-07-23T16:12:22Z",
"assignment_id": 1234,
"user_id": 1234,
"submission_type": "online_upload",
"workflow_state": "graded",
"grade_matches_current_submission": true,
"graded_at": "2015-11-12T20:22:50Z",
"grader_id": 1234,
"attempt": 1,
"excused": null,
"late": false,
"preview_url": "https://mysite.instructure.com/courses/1234/assignments/1234/submissions/1234?preview=1&version=1",
"attachments": [
{
"id": 5029,
"folder_id": 1234,
"display_name": "mysampledoc.docx",
"filename": "mysampledoc.docx",
"content-type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"size": 15081,
"created_at": "2015-07-23T16:12:21Z",
"updated_at": "2015-07-23T16:12:23Z",
"unlock_at": null,
"locked": false,
"hidden": false,
"lock_at": null,
"hidden_for_user": false,
"thumbnail_url": null,
"modified_at": "2015-07-23T16:12:21Z",
"locked_for_user": false,
"preview_url": "/api/v1/canvadoc_session?blob=%7B%22user_id%22:61240000000000033,%22attachment_id%22:5029,%22type%22:%22canvadoc%22%7D&hmac=0b1bcf1a12345fdaec654321d1e48c0bfc6b1167"
}
]
}
I hope this helps.
Thank you! I had a colleague who helped me and he confirmed what you said. My problem was I had https://canvas.instructure.com as the url root and not http://mysite.instructure.com.
This is an old post and it looks like the submission endpoint has changed in the last 10 years. I'm not seeing attachments as an available item for submissions, does anyone know where to find the submission url in order to download the submitted file?
Hi @mlewis23,
I don't think there have been any significant changes here actually. I just tested in our instance, and I still see the basic structure from the submissions API that @garth posted back in 2016. A couple things that might be throwing you off though..
I hope it is helpful to at least have someone else verify the behavior.
-Chris
Thanks. Yes, I do see the attachment data now. I didn't see it in the documentation (https://canvas.instructure.com/doc/api/submissions.html#method.submissions_api.index) and thought it had been removed from the endpoint. Thanks for the quick reply.
From the assignment endpoint I do see a link for 'submissions_download_url' to bulk download all the files. Is this the best available these days?
To interact with Panda Bot in the Instructure Community, you need to sign up or log in:
Sign In