Create a Quiz Question

Jump to solution
OliverKharas
Community Explorer

Hi all this is my POST request using Postman to create a quiz question.

https://canvas.instructure.com/api/v1/courses/2775624/quizzes/8044367/questions?"question_type"= "essay_question",&"question_name"= "QuestionOliverTest",

It works, but only creates a "text_only_question" not an essay question? Capture.PNG

0 Likes
1 Solution
James
Community Champion

@OliverKharas 

I don't use Postman, but that looks like a messed up request. There are extra quotes and commas that shouldn't be there. But since it's a POST and those parameters are not typically in the query string, I don't know if it's just the way you entered it here or the way it was entered in Postman.

What I'm seeing though is that basically none of your question came through and only the defaults are used.

To create a single quiz question, you need to wrap everything inside a question object.

It's question[question_type]=essay_question, not just question_type=essay_question.

One alternative is to wrap it in a JSON object and then be sure to include the content-type:application/json header. Depending on the language/library you're using, you may need to JSON.stringify that -- with the right settings, Postman can probably do that for you.

{
  "question" : {
    "question_type" : "essay_question",
    "question_name" : "OliverTest"
  }
}

I like the JSON style when programming because it's easier to work with objects than strings. I like it for illustration purposes because it's easier for people to see the structure.

View solution in original post