Getting a "Text only question" when using API to create quiz questions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2021
09:15 AM
I've been at this for the past 5 hours... I'm trying to upload questions from a JSON file to Canvas via Canvas' API, but all I can get is a blank, dummy-placeholder question. I am using cURL. Below is my JSON, cURL command, and output. What am I doing wrong!?
{
"question": {
"question_name": "Question 1",
"question_text": "question text goes here",
"question_type": "multiple_choice_question",
"points_possible": 10,
"answers": {
"0": {
"answer_text": "answer 1",
"answer_weight": 0
},
"1": {
"answer_text": "answer 2",
"answer_weight": 0
},
"2": {
"answer_text": "answer 3",
"answer_weight": 0
},
"3": {
"answer_text": "answer 4",
"answer_weight": 100
}
}
}
}
curl 'https://uc.instructure.com/api/v1/courses/1450168/quizzes/4569831/questions/' -H 'Authorization: Bearer MY_SUPER_SECRET_ACCESS_TOKEN' -d '@/Desktop/test.json' -H "Accept: application/json Content-Type: application/json" -X POST
Output in Terminal:
{"id":62578744,"quiz_id":4569831,"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}%