Reputation: 31300
There is an error on line 11 stating:
Requested entity was not found. (line 11, file "Code")
createdCourse = Classroom.Courses.get('Bio10');
The function:
function createA_NewCourse() {
var courseNew,createdCourse;
courseNew = Classroom.newCourse();
courseNew.name = "10th Grade Biology";
courseNew.id = "Bio10";
Logger.log("course.name " + courseNew.name);//Verify that name was set
createdCourse = Classroom.Courses.get('Bio10');//Try to get course by ID
Logger.log(createdCourse)
}
How is a new course created in Apps Script?
Upvotes: 0
Views: 1029
Reputation: 31300
There are specific values for the ownerId
that must be used. The ownerId
specifies the owner of the course. One of the valid ownerId
strings is "me" which is the requesting user.
Other valid owner ID strings are:
The email address of the user is self explanatory. I don't know where you get the numeric identifier of the user.
Without the ownerId
setting being set first, or being set to an invalid string, I was getting an error message:
The caller does not have permission
Upvotes: 0
Reputation: 13469
As stated by @Dean Ransevycz, there should be a create()
method.
Here's a sample code:
function createCourses() {
var course;
course = Classroom.newCourse();
course.name = "10th Grade Biology";
course.ownerId = "me";
//course.id = "Bio10";
course = Classroom.Courses.create(course);
Logger.log('%s (%s)', course.name, course.id);
var list = Classroom.Courses.list();
Logger.log(list);
}
You're getting an Requested entity was not found.
error since you might be using the wrong course id. And I guess you can't set an ID when creating a course. (Source.)
Upvotes: 1