The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
Hi All,
I am Abhishek Gupta, a TA at UC Davis.
I am trying to build an application that update grades for students for a particular assignment.
I am was able to query student id's.
However, I have trouble updating the grades. I have looked at the Submissions - Canvas LMS REST API Documentation
and tried it. My request returns a 200 code and a JSON object but the grade is not updated.
Below is the python code for updating grade for a single student for an assignment:
GRADE_URL = 'https://canvas.ucdavis.edu/api/v1/courses/' + course_id + '/assignments/' + assignment_id + '/submissions/' + user_id
#make the form data
data = { 'submission':{
'posted_grade': 8.0
}
}
#make the PUT request
userGrade = requests.put(GRADE_URL, headers = self.headers, data = data)
Any help in this regard will be much appreciated!#post grades
Solved! Go to Solution.
Hi Abhishek --
I think the issue is that the requests module is form-encoding your data by default rather than sending it as JSON-encoded data. To make the form-encoded PUT request work, you'd need to change your code to something like:
data = {
'submission[posted_grade]': 8.0
}
Alternatively, you could have the requests module send JSON-encoded data like this:
userGrade = requests.put(GRADE_URL, headers=self.headers, json=data)
Hope this is helpful!
--Colin
Hi Abhishek --
I think the issue is that the requests module is form-encoding your data by default rather than sending it as JSON-encoded data. To make the form-encoded PUT request work, you'd need to change your code to something like:
data = {
'submission[posted_grade]': 8.0
}
Alternatively, you could have the requests module send JSON-encoded data like this:
userGrade = requests.put(GRADE_URL, headers=self.headers, json=data)
Hope this is helpful!
--Colin
Hi Colin,
That resolved the issue.
Thanks a lot!
Best,
Abhishek Gupta
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in