Home > Mobile >  Directory API Google Apps Script retrieve groups with prefix?
Directory API Google Apps Script retrieve groups with prefix?

Time:09-07

Apparently the query parameter is being rejected from the following code, attempting to retrieve groups matching a given prefix:

  var OUPageToken;
  var groupList = AdminDirectory.Groups.list({
    customer:"my_customer", 
    domain: "mydomain.com",
    maxResults: 500,
    pageToken: OUPageToken,
    query: "'email=students*'"
    })["groups"];

Throws:

Error   
GoogleJsonResponseException: API call to directory.groups.list failed with error: Invalid Input: query

Could it be that the SDK version https://developers.google.com/admin-sdk/directory/reference/rest/v1/groups/list differs from the apps-script version https://developers.google.com/apps-script/advanced/admin-sdk-directory#list_all_groups ?

CodePudding user response:

Your query probably isn't formatted correctly. See guide.

Try the following:

  var groupList = AdminDirectory.Groups.list({
    customer:"my_customer", 
    domain: "mydomain.com",
    maxResults: 500,
    pageToken: OUPageToken,
    query: "email:students*"
    })["groups"];
  • Related