title: Google Drive API PHP - update content of txt file
body: <p>I created one folder and inside that folder I've created 2 text files, with some text inside. I can also list the files and get the text in them without problems. Now I am trying to update the text inside of that files, but I am always getting this error:</p>
  
  <pre><code>"domain": "global",
  "reason": "fieldNotWritable",
  "message": "The resource body includes fields which are not directly writable."
  </code></pre>
  
  <p>I created a function similar to the one presented in <a href="https://developers.google.com/drive/v2/reference/files/update" rel="nofollow">https://developers.google.com/drive/v2/reference/files/update</a>.</p>
  
  <p>I used this example because in version v3, Google don't present any example, and I can't find anything that can help me in this. My function is below.</p>
  
  <pre><code>function updateFile ($service, $fileId, $newTitle, $newDescription, $newMimeType, $text) {
      try {
          // First retrieve the file from the API.
          $file = $service-&gt;files-&gt;get($fileId);
  
          // File's new metadata.
          $file-&gt;setName($newTitle);
          $file-&gt;setDescription($newDescription);
          $file-&gt;setMimeType($newMimeType);
  
          // File's new content.
          $additionalParams = array(
              'data' =&gt; $text,
              'uploadType' =&gt; 'media'
          );
  
          // Send the request to the API.
          $updatedFile = $service-&gt;files-&gt;update($fileId, $file, $additionalParams);
          return $updatedFile;
      } catch (Exception $e) {
          print "An error occurred: " . $e-&gt;getMessage();
      }
  }
  </code></pre>
  
  <p>Thank you in advance.</p>