0

  var form = FormApp.openById('1IErsge8yafg0UOltvhecAMhRd5Yh1VXJdhkI');
  var groupID = "[email protected]";

  var formResponses = form.getResponses();
  for (var i = 0; i < formResponses.length; i++) {
    var formResponse = formResponses[i];
    var itemResponses = formResponse.getItemResponses();
    var email = itemResponses[1].getResponse();
    Logger.log(email);
    var newMember = {email: email, role: "MEMBER"};
    AdminDirectory.Members.insert(newMember, groupID);
  }

}

This is the code I've written and I'm getting an error enter image description here

After some research I found out that the error is because I don't have a G Suite subscription.

However, I am not able to find anything about how achieve the same task without a G Suite subscription. Can anyone please help me with that?

Thanks in advance!

5
  • You need the id. You can make a test request here and see the id. It looks like this: 22y111xx3f8ri5j That worked for me, just tested it. Commented Apr 10, 2022 at 19:00
  • Please add more details. Are you a Google Workspace Admin? Are you able to list the groups in your domain? P.S. Error messages should be added as text, not as images. P.S.S. Related stackoverflow.com/q/21253849/1595451 Commented Apr 10, 2022 at 19:28
  • In addition, you have an example in the official documentation: Add group member Commented Apr 11, 2022 at 12:00
  • @Rubén I am not a Google workspace admin. I'm quite new to stack overflow and I didn't know we were supposed to add error as text. Thanks for the information! Commented Apr 12, 2022 at 15:25
  • Thanks for your reply abhi. Please consider to edit the question to replace the error image by the error text. Commented Apr 12, 2022 at 15:31

1 Answer 1

3

As you aren't Google Workspace Admin, please checkout the Jay Lee's answer to Google Groups API add Member. Tl;Dr: AdminDirectory can be used only by Google Workspace Admins.

You might try to use the Groups Service to get information about a Google Group but it hasn't a method to add users to a group, so your only options are to add the users manually or to use web-browser automation tool.

Resources

Related

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.