0

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.

Rubén
  • 34,714
  • 9
  • 70
  • 166
James
  • 86
  • 1
  • 7
  • I'm not able to get the "Requested entity was not found." error, but instead I'm seeing a "Invalid JSON string: {}" error which I've reported to the engineering team. Any more specific steps required to get that error? – Eric Koleda Aug 06 '15 at 16:32
  • Hmm. That's odd. I get that error when I use the following line: var response = Classroom.Invitations.accept(id); – James Aug 07 '15 at 16:33
  • Yes, I should have mentioned, you should be passing the ID in directly, not in an object like in your sample above. – Eric Koleda Aug 10 '15 at 13:01

0 Answers0