API Content Migrations Copy course Unprocessable Entity

alexei-bezpaltc
Community Explorer

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!!!

0 Likes