AnsweredAssumed Answered

Adding answers to multiple choice quiz questions via Canvas API

Question asked by Alessandro Mottura on Jul 10, 2019
Latest reply on Aug 2, 2019 by Alessandro Mottura


I am trying to use the Canvas API to create quizzes on Canvas. I have managed to create quizzes in a course, and I have managed to add questions to the quizzes I created - no problems there. I am stuck at adding answers to multiple choice questions (either at the time of creating the question, or editing the question after creation).

The documentation (Quiz Questions - Canvas LMS REST API Documentation) does not seem to say very much, other than question[answers] should be an array. I have tried different structures for the data, and got nowhere. I used the Canvas Live API facility we have, and there is nothing I can write in the text box that returns a success code (I get a 500 server error as soon as I add a non-empy question[answers] array.

As an example, here is the payload (in Python) I pass to my POST request to create a question with answers:

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]': 0,
    'question[answers]': [
            'answer_text': 'Right answer',
            'answer_weight': 100
            'answer_text': 'Wrong answer',
            'answer_weight': 0

Any ideas? If I remove the question[answers] item from the dictionary, the POST request works fine. If I add it, I get an internal server error. Am I missing something obvious?

I get the same exact behaviour when I use the Canvas Live API. If I select the function to create a quiz question, the page displays the input parameters. I can use this successfully to create a quiz question, but there is nothing I managed to write in the box below that resulted in the creation of a multiple choice quiz question with answers.