I am trying to upload a bundle with the android publisher api of google using Node.js :
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 => {
let chunks = [];
res.on('data', chunk => chunks.push(chunk));
res.on('end', () => console.log(Buffer.concat(chunks).toString()));
})
.end(fs.readFileSync(bundle_path));
But its returning an error
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unexpected token.\nPK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u000eOTR%\n^",
"status": "INVALID_ARGUMENT"
}
}
I can't find what is missing in my Node.js code.