AnsweredAssumed Answered

How do I create quiz question via API?

Question asked by Boris Kheyfets on Jul 23, 2018
Latest reply on Jul 24, 2018 by Boris Kheyfets



I'm trying to create a question to an existing quiz via API.

The doc is here: Quiz Questions - Canvas LMS REST API Documentation 

So I made a simple data.json:

  "question": {
    "question_name": "Question",
    "question_text": "<p>test</p>",
    "question_type": "essay_question",
    "points_possible": 1

and send it to the canvas:

curl -s 'https://canvas.url/api/v1/courses/1571/quizzes/517/questions' -X POST -d @data.json   -H "Authorization: Bearer $CANVAS_TOKEN" | jq -r '.'

But canvas ignored all my fields, and created a dummy question instead:

  "id": 1446,
  "quiz_id": 517,
  "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

Could it be the case of question API does not work?