[ARCHIVED] Error creating RubricAssessment via the Canvas API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am having trouble submitting a RubricAssessment via the Canvas API. I am following this Create a single rubric assessment API doc. Below is what I have attempted along with example data and error message. What is wrong with my RubricAssessment POST?
GET /api/v1/courses/1022/rubrics/500?include[]=associations
Response(contains the RurbricAssociation id and Criterion ids needed to create RubricAssessment)
{
id: 500,
context_id: 1022,
context_type: 'Course',
data: [
{
description: 'Student can clearly communicate...',
points: 3,
id: '_340',
criterion_use_range: false,
long_description: '<p> Desc...</p>',
learning_outcome_id: 6379,
mastery_points: 2,
ignore_for_scoring: false,
ratings: [Array]
},
{
description: 'Student can clearly articulate their collaboration',
points: 3,
id: '_2874',
criterion_use_range: false,
long_description: '<p><b>1</b>: Long desc...</p>',
learning_outcome_id: 6378,
mastery_points: 2,
ignore_for_scoring: false,
ratings: [Array]
},
{
description: 'Student publishes a clearly articulated...',
points: 3,
id: '_2311',
criterion_use_range: false,
long_description: "<p>Long desc...</p>\n",
learning_outcome_id: 6380,
mastery_points: 2,
ignore_for_scoring: false,
ratings: [Array]
}
],
points_possible: 9,
title: 'Sprint Challenge 2 Rubric',
reusable: false,
public: false,
read_only: false,
free_form_criterion_comments: true,
hide_score_total: null,
associations: [
{
id: 750,
rubric_id: 500,
association_id: 18647,
association_type: 'Assignment',
use_for_grading: true,
summary_data: null,
purpose: 'grading',
hide_score_total: false,
hide_points: false,
hide_outcome_results: false
}
]
}
POST to : /api/v1/courses/1022/rubric_associations/750/rubric_assessments (1022 is a course, 750 is a rubric_association)
Request Payload:
{
"rubric_assessment": {
"course_id": 1022,
"rubric_association_id": 750,
"rubric_assessment": {
"user_id": 1934,
"assessment_type": "grading",
"criterion_340": { "points": 2, "comments": "Test comment 1" },
"criterion_2874": { "points": 2, "comments": "Test comment 2" },
"criterion_2311": { "points": 2, "comments": "Test comment 3" }
}
}
}
Response:
{"errors":[{"message":"The specified resource does not exist."}]}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was able to successfully use the API to update rubric assessments, although it took a lot more time than it should have. Two things caused me trouble:
- lack of clarity in the API, and
- Canvas not accepting JSON objects for this particular call.
The way I figured it out was I used Chrome's Developer Tools (ctrl + shift + i on Win, optn + cmd + i on Mac), then Networks to see the internal calls. All the internal calls were being made as url parameters, not by passing JSON objects. The other thing I discovered is that a double underscore is required for the criterion IDs. The documentation states under updating a single rubric assessment:
For each criterion_id, change the id by the criterion number, ex: criterion_123 If the criterion_id is not specified it defaults to false, and nothing is updated.
The documentation isn't technically wrong, being as you concatenating "criterion_" + id will give you the correct code, but the ids have a built-in underscore, e.g. "_123", so the end result should be "criteiron__123", but the documentation shows a single underscore, which I think is misleading and being as the original poster made the same mistake, it's not just me.
In order for the original poster's rubric assessment to work, it'd have to be passed as query parameters to the API call and should look something like this:
?rubric_assessment[user_id]=5472&rubric_assessment[assessment_type]=grading&rubric_assessment[criterion__340][points]=2&rubric_assessment[criterion__2874][points]=2&rubric_assessment[criterion__2311][points]=2
My code implementation built an array of JSON objects, so I added a last bit of code that converted each JSON object into a string that looked something like the code above. I stuck each string at the end of my POST requests and voila! I stopped getting error messages and the rubric assessments started to appear on the assignments.
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.