Canvas API POST quiz question not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2022
09:30 PM
I've been attempting to create quizzes via the canvas api, but am running into issue (exacerbated by the less-than-ideal error handling by the canvas api).
I'm able to create a quiz, but when trying to create a quiz question, I've run into the following two errors:
- A 500 error with no detail on the payload issue
- A 200, but none of the parameters I'm passing are used and I'm left with a blank quiz question
Here is a sample request:
r = requests.post(
url + '/v1/courses/' + str(course_id) + '/quizzes/' + str(quiz_id) + '/questions',
headers = auth,
json = question
)
where...
question = {
"question[question_name]" : "Question 1",
"question[question_text]" : "This is a question, pick an answer",
"question[question_type]" : "multiple_choice_question",
"question[points_possible]" : 1,
"question[answers]" : [
{
"answer_text" : "It worked!",
"answer_weight" : 100
},
{
"answer_text" : "This did not work",
"answer_weight" : 0
}
]
}
Here is the response I get:
200 { "id": 160769, "quiz_id": 48977, "quiz_group_id": null, "assessment_question_id": null, "position": null, "question_name": "Question", "question_type": "text_only_question", "question_text": "Question text", "points_possible": 0, "correct_comments": "", "incorrect_comments": "", "neutral_comments": "", "correct_comments_html": "", "incorrect_comments_html": "", "neutral_comments_html": "", "answers": [], "variables": null, "formulas": null, "answer_tolerance": null, "formula_decimal_places": null, "matches": null, "matching_answer_incorrect_matches": null, "assessment_question": null }
Any help here would be appreciated.