Search code examples
phpgoogle-api-php-clientbad-request

400 (Bad Request) when calling listGroups() method with Google API PHP client


I want to retrieve all groups in my domain. I'm using google api php client and have the following error when i try it :

$client = new Google_Client();

...

$directory = new Google_Service_Directory($client);

$directory->groups->listGroups();

Error calling GET https://www.googleapis.com/admin/directory/v1/groups: (400) Bad Request

Do you know how can i fix it ?


Solution

  • The problem has been fixed. I had to specify a domain in the listGroups() function :

    $directory->groups->listGroups(array('domain' => 'mydomain.com'));