[ARCHIVED] Why Create Course with API Returns 404

Jump to solution
cluemyeein
Community Novice

course‌

Hi,

I'm attempting to create a course using this api from within Postman: 

POST /v1/accounts/{account_id}/courses 

Request JSON

{
"course": {
"name" : "API Development Test in Postman Term Test",
"course_code" : "1",
"start_at" : "2020-09-27T11:43:36.174Z",
"end_at" : "2020-10-27T11:43:36.174Z",
"license" : "private",
"is_public" : true,
"is_public_to_auth_users" : false,
"public_syllabus" : true,
"public_syllabus_to_auth" : false,
"public_description" : "This course will help you to learn how to create APIs using Java.",
"allow_student_wiki_edits" : false,
"allow_wiki_comments" : true,
"allow_student_forum_attachments" : true,
"open_enrollment" : true,
"self_enrollment" : true,
"restrict_enrollments_to_course_dates" : true,
"hide_final_grades" : true,
"apply_assignment_group_weights" : true,
"time_zone" : "Asia/Kolkata",
"default_view" : "feed",
"syllabus_body" : "This is dummy syllabus body",
"term_id": "1"
"offer" : true,
"enroll_me" : true,
"enable_sis_reactivation" : false
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The response is:

{
    "errors": [
        {
            "message""The specified resource does not exist."
        }
    ]
}
However, if I changed the request JSON to skip term_id:
{
"course": {
"name" : "API Development Test in Postman Term Test",
"course_code" : "1",
"start_at" : "2020-09-27T11:43:36.174Z",
"end_at" : "2020-10-27T11:43:36.174Z",
"license" : "private",
"is_public" : true,
"is_public_to_auth_users" : false,
"public_syllabus" : true,
"public_syllabus_to_auth" : false,
"public_description" : "This course will help you to learn how to create APIs using Java.",
"allow_student_wiki_edits" : false,
"allow_wiki_comments" : true,
"allow_student_forum_attachments" : true,
"open_enrollment" : true,
"self_enrollment" : true,
"restrict_enrollments_to_course_dates" : true,
"hide_final_grades" : true,
"apply_assignment_group_weights" : true,
"time_zone" : "Asia/Kolkata",
"default_view" : "feed",
"syllabus_body" : "This is dummy syllabus body"
},
"offer" : true,
"enroll_me" : true,
"enable_sis_reactivation" : false
}
Then, a course is created but the course name and code are persisted but term is not set:

{
"id": 1392070,
"root_account_id": 228,
"enrollment_term_id": 88,
"restrict_enrollments_to_course_dates": true,
"start_at": "2020-09-27T11:43:36Z",
"account_id": 18135,
"uuid": "YyHCpkW0K41CoMSShZNAPtgSTVbpnljCeRb73YjG",
"name": "API Development Test in Postman Term Test",
"grading_standard_id": null,
"is_public": true,
"created_at": "2020-05-14T13:08:37Z",
"allow_student_forum_attachments": true,
"course_code": "1",
"default_view": "feed",
"open_enrollment": true,
"allow_wiki_comments": true,
"self_enrollment": true,
"license": "private",
"public_description": "This course will help you to learn how to create APIs using Java.",
"grade_passback_setting": null,
"end_at": "2020-10-27T11:43:36Z",
"public_syllabus": true,
"public_syllabus_to_auth": false,
"storage_quota_mb": 50000,
"is_public_to_auth_users": false,
"hide_final_grades": true,
"apply_assignment_group_weights": true,
"calendar": {
"ics": "https://<our host>/feeds/calendars/course_YyHCpkW0K41CoMSShZNAPtgSTVbpnljCeRb73YjG.ics"
},
"time_zone": "Asia/Kolkata",
"blueprint": false,
"sis_course_id": null,
"sis_import_id": null,
"integration_id": null,
"workflow_state": "available"
}

 

What is the proper request JSON?

Labels (2)
0 Likes
1 Solution
cluemyeein
Community Novice
Author

Yes, I did leave it out by accident but had it in my request data. 

I finally figured out my error.  The term_id was throwing the 404 because I was setting it to a non-existent term.  Once I've removed that field from the request body, I was able to create a course successfully.

Wish the error was a bit more precise as far as what resource was non-existent in the 404 message.  Something like term_id returns null would be extremely helpful.

Thank you James and David for jumping in so quickly!

Thanks,
Janice

View solution in original post

0 Likes