The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
Hello!
I am trying to create a copy of a course. I created a new empty course via API (So I know my POST routine is working) Course id is 148. My template course has id 33,
then I do
string command = "POST /api/v1/courses/148/content_migrations"
var stringContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("migration_type", "course_copy_importer"),
new KeyValuePair<string, string>("settings[source_course_id]", "33"),
});HttpResponseMessage myResponse = await clsHttpMethods.httpPOST(CanvasSettings.CanvasURL, command, CanvasSettings.AccessToken, stringContent);
var content = await myResponse.Content.ReadAsStringAsync();
In HttpResponseMessage I'm getting
StatusCode: 422, ReasonPhrase: 'Unprocessable Entity'
In Response.Content I'm getting HTML page (not JSON) saying
Page Error
There was a problem with your last request. You may have tried to perform an action after a long period of inactivity. If that's the case, try going back, reloading the page you were working on, and resubmitting. If not, please let us know what you were doing when the error happened.
Any idea what may be going on here?
Thanks!!!
Hey Alexei B,
Below is how I am able to call the content migration API.
MigrationURL = string.Format("{0}{1}{2}{3}"
, CanvasUrl
, "/api/v1/courses/"
, CanvasCourseSISID
, "/content_migrations");
string Parameters = string.Format("migration_type=course_copy_importer&settings[source_course_id]={0}", CourseToCopyContentFromCanvasSISID);
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
wc.Headers[HttpRequestHeader.Authorization] = string.Format("{0}{1}", "Bearer ", AuthToken);
s = wc.UploadString(MigrationURL, Parameters);
}
Hope this helps.
Oh! you are using destination and template courses SISID ? let me try that. Thanks!
Yes the source_course_id is the template course SIS ID, while the CanvasCourseSISID is the Canvas Course SIS ID of the course you want to copy the content into.
I had my command url incorrectly (silly copy/paste error)
string command = "POST /api/v1/courses/148/content_migrations"
After fixing that it worked using course id (NOT sis id) for both source and destination courses.
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in