我编写了一个 API 来在 Desire2Learn 中创建 CreateCourseOffering
http://docs.valence.desire2learn.com/res/course.html#post--d2l-api-lp-(D2LVERSION-version)-courses-
我为此调用了上面的 API。代码执行得很好,我没有找到任何创建的课程。在下面粘贴我的代码。请建议其中有什么问题
我的输入
objCourse.Code = "1234567";
objCourse.Name = "TCS_TestCourse2";
objCourse.path = "/content/Traning";
objCourse.ForceLocale = false;
objCourse.ShowAddressBook = false;
objCourse.CourseTemplateId = 10;
我的代码
UriBuilder baseUri = new UriBuilder(userContext.CreateAuthenticatedUri("/d2l /api/lp /1.0/courses/", "POST"));
CreateCourse objCreateCourse = new CreateCourse();
objCreateCourse.Code = objCourse.Code;
objCreateCourse.Name = objCourse.Name;
objCreateCourse.path = objCourse.path ;
objCreateCourse.ForceLocale = objCourse.ForceLocale;
objCreateCourse.ShowAddressBook = objCourse.ShowAddressBook;
objCreateCourse.CourseTemplateId = objCourse.CourseTemplateId;
JavaScriptSerializer serializer1 = new JavaScriptSerializer();
string createCourseData = serializer1.Serialize(objCreateCourse);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseUri.Uri);
request.Method = "POST";
request.AllowAutoRedirect = false;
byte[] bytes;
bytes = System.Text.Encoding.ASCII.GetBytes(createCourseData);
request.ContentLength = bytes.Length;
request.ContentType = "application/json";
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(bytes, 0, bytes.Length);
// Close the Stream object.
dataStream.Close();