Add comments (text) via Python API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2018
03:23 PM
Hello,
I am trying to upload a string as a comment for one student, one submission using Python API. (I have Python 3) I am able to upload the file but not the string.
Here's the code I have so far and it works for uploading file. I tried submission.edit() but couldn't get it to work.
API_URL = 'https://canvas api url' ## Canvas API URL
API_KEY = "canvas api key" ## Canvas API key
COURSE_ID = 1234 #COURSEID
ASSIGNMENT_ID = 123456 #Assignment ID
canvas = Canvas(API_URL, API_KEY)
course = canvas.get_course(COURSE_ID)
assignment = course.get_assignment(ASSIGNMENT_ID)
submissionuser_234581 = assignment.get_submission(user = 12345)
submissionuser_234581.upload_comment(file='sample.txt')
Any help much appreciated. (If I have posted in wrong forum please let me know - first time post here)
Solved! Go to Solution.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2019
01:22 PM
Took me a long time as well, but this should work! This can't be combined with the file comment, so that will create two seperate comments.
submission.edit(submission={comment={'text_comment':'Write your comment here'})