title: How can I create a folder within a Team Drive with the Google API?
body: <p>I'm struggling to create a folder within a Team Drive using the Google API PHP Client Library.</p>
  
  <p>I am using a service account and impersonating a user (myself) who is a member of the Team Drive and can list the contents of the drive. However, when I create a folder it always creates it in 'My Drive' rather than the Team Drive specified.</p>
  
  <p>Attempt 1</p>
  
  <pre><code>$client = new Google_Client();
  $client-&gt;useApplicationDefaultCredentials();
  $client-&gt;addScope("https://www.googleapis.com/auth/drive");
  $client-&gt;setSubject('user@mydomain.com');
  
  $service = new Google_Service_Drive($client);
  
  $folderId = '0AIuzzEYPQu9CUk9PVA';
  $fileMetadata = new Google_Service_Drive_DriveFile(array(
      'name' =&gt; 'New Test Folder',
      'mimeType' =&gt; 'application/vnd.google-apps.folder',
      'supportsAllDrives' =&gt; true,
      'parents' =&gt; ['0AIuzzEYPQu9CUk9PVA']
  ));
  </code></pre>
  
  <p>Attempt 2</p>
  
  <pre><code>$fileMetadata = new Google_Service_Drive_DriveFile(array(
      'name' =&gt; 'New Test Folder',
      'mimeType' =&gt; 'application/vnd.google-apps.folder',
      'supportsAllDrives' =&gt; true,
      'driveId' =&gt; '0AIuzzEYPQu9CUk9PVA'
  ));
  </code></pre>
  
  <p><strong>UPDATE Attempt 3</strong></p>
  
  <pre><code>$fileMetadata = new Google_Service_Drive_DriveFile(array(
      'name' =&gt; 'Hello 123',
      'supportsAllDrives' =&gt; true,
      'mimeType' =&gt; 'application/vnd.google-apps.folder',
      'parents' =&gt; ['0AIuzzEYPQu9CUk9PVA']
  ));
  
  $file = $service-&gt;files-&gt;create($fileMetadata, array(
        'fields' =&gt; 'id'));
      printf("Folder ID: %s\n", $file-&gt;id);
  </code></pre>
  
  <p>Attempt 3 gives this error:
  Fatal error: Uncaught Google_Service_Exception: { "error": { "errors": [ { "domain": "global", "reason": "notFound", "message": "File not found: 0AIuzzEYPQu9CUk9PVA.", "locationType": "parameter", "location": "fileId" } ]</p>
  
  <p>I have read all the (limited) <a href="https://developers.google.com/drive/v3/web/about-teamdrives" rel="nofollow noreferrer">documentation</a> regarding Team Drive and the API and understand that a folder/file within a Team Drive can only have one parent (The Team Drive's ID) so I have tried variations of the parent as an array and string.</p>
  
  <p>The folder is created correctly, just in the wrong place.</p>