[ARCHIVED] Setting grades using canvas API

colodzin
Community Novice

I am working with the Canvas API to populate Canvas courses with data from a different LMS. We have been able to create the course, populate the membership, and pull in assignments.

Where I'm stuck is in pushing over grade data. I am doing this by creating a submissions for a given assignment for a given student, and setting a grade. I add parameter as_user_id=sis_user_id:xxx where xxx is the sis_user_id of a professor in the course. But I am getting an 'unauthorized' error. I also tried using the sis_user_id of the relevant student, but got the same 'unauthorized' error.

My questions are:

1. What permissions do I need to be aware of, or somehow address to be able to set grades/create submissions via the API? 

2. To bring grades over, would the appropriate steps be to just create a Submission via a POST and include the grade, or do I need to create a submission via a POST, and then make a PUT call to update it to set the grade?

3. As an alternative, the update_grades call seemed a good way to potentially make a single bulk call. However I was unable to get this working either -- I'm not even entirely clear in what format that data should be passed -- is it simple text rather than json? I was testing in postman, but got an internal server error, so clearly I am not sending data in the correct format (error_report_id"1052166532)

curl 'https://<canvas>/api/v1/courses/1/assignments/2/submissions/update_grades' \      -X POST \      -F 'grade_data[3][posted_grade]=88' \      -F 'grade_data[4][posted_grade]=95' \      -H "Authorization: Bearer <token>"

Any suggestions would be greatly appreciated!

Robin Colodzin

Labels (2)