@colodzin
If you have admin permissions, you don't need to make the call as the instructor. If you have the permissions to masquerade as the user, then you probably have permissions to update the grades.
The unauthorized error is possibly due to you not having the correct IDs. If you are using the 1, 2, 3, or 4, which is what Canvas shows in their grade or comment on multiple submissions endpoint of the Submissions API documentation, then you are almost certainly going to get this error.
If any of the three IDs (course_id, assignment_id, or student_id) are incorrect, then you could be getting the unauthorized error since that course, assignment, or student potentially belongs to some one else. This is especially true when you're not self-hosting (you didn't say whether you were or not).
You also need to make sure to use the instance of your Canvas, not the free for teachers shown in the example.
The call should look something like this:
POST richland.instructure.com/api/v1/courses/896851/assignments/10638275/submissions/update_grades?grade_data[3346297][posted_grade]=2
Of course, this needs changed to your values, you will get an unauthorized error if you try it directly.
The student_id=3346297 (I don't know that you can use the SIS student ID here, but it would look like sis_student_id:123456 if you could), the Canvas assignment ID is 10638275, the Canvas course ID is 896851, and the student received a grade of 2.
You can repeat that form data multiple times, once for each student. The example given in the Canvas API documentation shows updating the grade for two students.
You are welcome to use command line CURL, as shown in the example, but most people use a library for whatever programming language they're using.
You make that POST and include the form data as a query parameter as shown above. Technically, you should probably URI encode the query parameter so that [ becomes %5B and ] becomes %5D, but it works as it is.
I don't use Postman, but the basics are the same no matter what program you use. You should not be sending this as JSON unless you also send the correct headers to tell it that the content-type is application/json. If you are using form-data, then it uses a key=value combination. The key would be grade_data[3346297][posted_grade] and the value would be 2.
If you want to use JSON, then it should look like this (I think, I just typed this up without testing it).
{
"grade_data":{
"3346297":{
"posted_grade":2
}
}
}
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.