title: Invalid value for ByteString error when calling gmail send API with base64 encoded < or >
body: <p>Really stuck on this one and pulling my hair out trying to figure out what to do, searched everywhere and tried everything but still stuck. Any help is much appreciated.</p>
  
  <p>So I am calling the Gmail send message API:</p>
  
  <p><a href="https://www.googleapis.com/gmail/v1/users/me/messages/send">https://www.googleapis.com/gmail/v1/users/me/messages/send</a></p>
  
  <p>I pass in the following base64 encoded raw message:</p>
  
  <blockquote>
    <p>VG86IGVjaG9zaWduLnNmZGMucWFAZ21haWwuY29tDQpTdWJqZWN0OiBSZTogd2UgaGF2ZSBhIGNvb2wgcHJvZHVjdA0KSW4tUmVwbHktVG86IDxDQUFMRnBBSmc1aTJlQ1p4T2dQWlhUdnNaN0J5M0gzNlRCMkNQYTdoVEtzTXh2bXZfT3dAbWFpbC5nbWFpbC5jb20+DQpSZWZlcmVuY2VzOiA8Q0FBTEZwQUpnNWkyZUNaeE9nUFpYVHZzWjdCeTNIMzZUQjJDUGE3aFRLc014dm12X093QG1haWwuZ21haWwuY29tPg0KDQoxMTozNg==</p>
  </blockquote>
  
  <p>Which decodes to:</p>
  
  <pre><code>To: echosign.sfdc.qa@gmail.com
  Subject: Re: we have a cool product
  In-Reply-To: &lt;CAALFpAJg5i2eCZxOgPZXTvsZ7By3H36TB2CPa7hTKsMxvmv_Ow@mail.gmail.com&gt;
  References: &lt;CAALFpAJg5i2eCZxOgPZXTvsZ7By3H36TB2CPa7hTKsMxvmv_Ow@mail.gmail.com&gt;
  
  11:36
  </code></pre>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>Status code: 400 and status: Bad Request and response: { "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "Invalid value for ByteString</p>
  </blockquote>
  
  <p>The problem is the less than <code>&lt;</code> and greater than <code>&gt;</code> symbols in the In-Reply-To and References headers. I need those headers because I am trying to have the email come as a reply on the thread. I tried to leave out the <code>&lt;</code> and <code>&gt;</code> but the reply then does not thread.</p>
  
  <p>Thanks</p>