I know this is two-in-a-row, but they're different issues, so I thought it best to split them up. I'm getting problems with accepting invitations on behalf of students. I'm a super admin within the domain, and it works through the API explorer, but not through Google Apps Script's Advanced Service for Classroom. And before you ask, yes, I did enable Classroom in both the Advanced Services menu and Developer's Console.
Here's the block of code:
function invitations() {
var classList = Classroom.Courses.list().courses;
for (i in classList) {
var classId = classList[i].id;
var teacher = Classroom.Courses.Teachers.get(classId, classList[i].ownerId).profile.name.fullName;
if (teacher == 'FULL_NAME_GOES_HERE') { // I had entered my full name here as a string. If testing, you can replace with your own
var title = Classroom.Courses.get(classId).name;
Logger.log('Teacher: %s, Title: %ss',teacher,title);
var list = Classroom.Invitations.list({'courseId':classId}).invitations;
if (list) {
Logger.log('list');
for (k in list) {
var invitation = list[k];
var student = invitation.userId;
var id = invitation.id;
var response = Classroom.Invitations.accept({id:id});
Logger.log('ID: %s',id);
}
}
}
}
}
The id being passed to Classroom.Invitations.accept returns an error "Requested entity was not found." but when I input the same ID into the API explorer, it returns 200 - OK. Is this a problem with the Authorization scope? I have authorization to manage Classroom rosters, which I believe this falls under.