title: How sync a DRAFT email to a existing thread in Gmail having attachment over 20MB using Gmail API
body: <p>I'm using MediaFileUpload class to create an email message with attachments having size more than 20MB. I have gone through Gmail API uploading attachments documentation. But below exception appears all the time. Please help me in resolving this case.</p>
  
  <pre><code>    $service = $this-&gt;getClientService();
      $client = $this-&gt;getClientConnection();
  
      $draft = new Google_Service_Gmail_Draft();
      $draft-&gt;setMessage($message);
  
      // mime message format
      $rawMessage = $this-&gt;getOriginalRawMessage();
      $client-&gt;setDefer(TRUE);
      try {
          $request = $service-&gt;users_drafts-&gt;create($userId, $draft,['uploadType' =&gt; 'multipart']);
          $media = new Google_Http_MediaFileUpload($client, $request, 'multipart/related',$rawMessage, false, self::MESSAGE_UPLOAD_CHUNK_SIZE);
          $media-&gt;setFileSize(strlen($rawMessage));
          // Upload the various chunks. $draftResponse will be false until the process is complete.
          $mediaResponse = false;
          while (!$mediaResponse) {
              $mediaResponse = $media-&gt;nextChunk();
          }
          $client-&gt;setDefer(false);
  
        return $mediaResponse;
  </code></pre>
  
  <p>Getting exception as</p>
  
  <pre><code>{
   "error": {
    "errors": [
     {
      "domain": "global",
      "reason": "badContent",
      "message": "Media type 'application/json; charset=UTF-8' is not supported. Valid media types: [message/rfc822]"
     }
    ],
    "code": 400,
    "message": "Media type 'application/json; charset=UTF-8' is not supported. Valid media types: [message/rfc822]"
   }
  }
  </code></pre>