Steps to duplicate a course via the Canvas API

Jump to solution
nbpenn
Community Member

Hi - I'm just starting to dig into using the Canvas API - first task is to figure out how to copy a course.

I've seen a few posts but most are at least a couple years old, so I'm going to repost just in case there's a more modern way to do it or if there are new resources/documentation available.

I created a Test Course, and the API says to copy the course, I send a request to create a 'content_migration' - done. The response is:

{
"id": 22486464,
"user_id": 4733452,
"workflow_state": "running",
"started_at": "2023-12-05T20:34:33Z",
"finished_at": null,
"migration_type": "course_copy_importer",
"created_at": "2023-12-05T20:34:33Z",
"migration_issues_url": "[canvas url]/api/v1/courses/1760609/content_migrations/22486464/migration_issues",
"migration_issues_count": 0,
"settings": {
"source_course_id": 1760609,
"source_course_name": "Test Course",
"source_course_html_url": "[canvas url]/courses/1760609"
},
"progress_url": "[canvas url]/api/v1/progress/28890266",
"migration_type_title": "Course Copy"
}
 
Checking the progress_url, it shows me that it's complete:
 
{
"id": 28890266,
"context_id": 22486464,
"context_type": "ContentMigration",
"user_id": 4733452,
"tag": "content_migration",
"completion": 100.0,
"workflow_state": "completed",
"created_at": "2023-12-05T20:34:33Z",
"updated_at": "2023-12-05T20:34:38Z",
"message": null,
"url": "[canvas url]/api/v1/progress/28890266"
}
 
 
 All seems to be working as expected, except: no where in the responses is an id or title for the new course, and no new course is visible in the admin; so - does this work, and if so, how do I fetch the id/title of the newly copied course?
 
2nd question - this seems to be a forum for admins - is there a developer specific forum?
 
Thanks for any insights!
 
 
Labels (1)
0 Likes
1 Solution
dgrobani
Community Champion

As I understand it, a content migration copies content from one course to another, and you must create the destination course first if it doesn't already exist.

When creating the content migration, you specify the destination course ID in the URL and the source course ID in the settings[source_course_id] request parameter.

View solution in original post

0 Likes