title: POST file upload, Invalid JSON payload
body: <p>I am trying to upload a bundle with the <a href="https://developers.google.com/android-publisher/api-ref/rest/v3/edits.bundles/upload" rel="nofollow noreferrer">android publisher api of google</a> using Node.js :</p>
  <pre><code>const https = require('https');
  const fs = require('fs');
  
  const bundle_path = ...
  const package = ...
  const editID = ...
  const token = ...
  
  const options = {
    hostname: 'androidpublisher.googleapis.com',
    port: 443,
    path: `/androidpublisher/v3/applications/${package}/edits/${editID}/bundles/`,
    method: 'POST',
    headers: {
      Authorization: `Bearer ${token}`,
      'Content-Type': 'application/octet-stream',
      'Content-Length': fs.statSync(bundle_path).size
    }
  };
  
  https.request(options, res =&gt; {
    let chunks = [];
    res.on('data', chunk =&gt; chunks.push(chunk));
    res.on('end', () =&gt; console.log(Buffer.concat(chunks).toString()));
  })
  .end(fs.readFileSync(bundle_path));
  
  </code></pre>
  <p>But its returning an error</p>
  <pre><code>{
    &quot;error&quot;: {
      &quot;code&quot;: 400,
      &quot;message&quot;: &quot;Invalid JSON payload received. Unexpected token.\nPK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u000eOTR%\n^&quot;,
      &quot;status&quot;: &quot;INVALID_ARGUMENT&quot;
    }
  }
  </code></pre>
  <p>I can't find what is missing in my Node.js code.</p>