I just ran a sample code from Apps Script tutorial:
https://developers.google.com/apps-script/reference/groups/group#getGroups()
(I have commented out the loop part to make the problem clear.)
function listGroupMembers() {
var GROUP_EMAIL = "a-group@in.mydomain";
var group = GroupsApp.getGroupByEmail(GROUP_EMAIL);
Utilities.sleep(10000);
var childGroups = group.getGroups();
console.log("Group " + GROUP_EMAIL + " has " + childGroup.length + " groups:");
/* comment out the loop to make the problem clear.
for (var i = 0; i < childGroups.length; i++) {
var childGroup = childGroups[i];
console.log(childGroup.getEmail());
}
*/
}
But I keep getting the following exception:
Exception: Service invoked too many times in a short time: groups read. Try Utilities.sleep(1000) between calls.
listGroupMembers @ test.gs:6
Even if I run a script for the first time in the last 24 hours, I get this exception. Any advice?
It must be the limitation of getGroups()
.
I tested a group with changing the number of child groups. Below is the result.
Looks like we can use getGroups()
only when the number child groups is 7 or less.
getEmail()
. Even if the function was executed once, consecutive childGroup.getEmail()
was called many times inside the loop in a short duration of time going past the quota.sleep
function inside the loop so it pauses every loop, thus reducing the calls done per minute/hour. See if that alleviates the problem. for (var i = 0; i < childGroups.length; i++) {
var childGroup = childGroups[i];
console.log(childGroup.getEmail());
Utilities.sleep(10000);
}
childGroups
. If that goes beyond the limit, try to limit your loop into 1950/9950 if it fixes the problem. If that fixes it, then it is confirmed that your function fails because of the quota being reached. for (var i = 0; i < 1950; i++) { // or 9950, depending on the account
var childGroup = childGroups[i];
console.log(childGroup.getEmail());
Utilities.sleep(10000);
}
i have the same issue? any news or solution? i think it is a bug because i didnt exceed the quota
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.