AnsweredAssumed Answered

Add comments (text) via Python API

Question asked by Rashmi Banthia on Dec 16, 2018
Latest reply on Jan 2, 2019 by jasper van der Heide

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)

Outcomes