0

From elswhere in stack exchange, I have found references to these code snippets working successfully, but fail when I run them.

Two sets of code below both of which result in an error - 'the requested entity was not found'. This is odd because if I change "remove" to "create", the function succeeds, so I am assuming all scopes are in place.

function removeStudents() {
//Classroom.Courses.Students.remove({
// userId: "[email protected]",
//}, 727305413955);


var ClassroomID=727305413955
var TeacherslistID="[email protected]";
Classroom.Courses.Teachers.remove({"userId":TeacherslistID},ClassroomID)
}

The error lists this line at fault is -- Classroom.Courses.Students.remove

Any help is appreciated

I was expecting that the student or Tutor would be removed from the classroom. I have tried this where the student has accepted the invitation and also whilst they remain in the invited state - both with the same error. For my use case I wish to remove students who are invited and not yet accepted.

1 Answer 1

2

In the case of "Method: courses.teachers.delete" with Advanced Google services, you can use as follows.

Classroom.Courses.Teachers.remove(courseId: string, userId: string)

This can be confirmed with the auto-completion of the script editor. Ref

When your script is modified, it becomes as follows.

Modified script:

Before you use this script, please confirm whether Google Classroom API has already been enabled at Advanced Google services, again.

Please set your values of courseId and userId. In your script, when ClassroomID and TeacherslistID are courseId and userId, respectively, you can use them.

var courseId = "###";
var userId = "###";
var res = Classroom.Courses.Teachers.remove(courseId, userId);
console.log(res);

Reference:

3
  • Many thanks for the quick reply. I assume you mean services available in the left of the app script page. I have Admin Directory, Docs, Drive, Sheets, Gmail and Classroom (v1). I take it that this should be sufficient? Commented Nov 28, 2024 at 10:55
  • BUT super and many thanks - your code worked fine, so I am not sure why mine didn't .... an error somewhere! Commented Nov 28, 2024 at 11:02
  • 1
    @Class Admin Thank you for replying. About your code worked fine, I'm glad your issue was resolved. About so I am not sure why mine didn't .... an error somewhere!, in your showing script, {"userId":TeacherslistID} and ClassroomID are used as the 1st and 2nd arguments. But, the correct arguments are courseId: string and userId: string, respectively. This modification made the script work correctly.
    – Tanaike
    Commented Nov 28, 2024 at 13:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.