Thanks @bjrmatos
i looked at https://github.com/jsreport/jsreport-import-export/blob/master/cli/import.js#L226 and found the logic to call the api now it works for me.
The i developed is as follows:
async function startImport(zipFileToImport, jsreportUrl, jsreportAuthrization) {
let form = new FormData();
await form.append('import.zip', fs.createReadStream(zipFileToImport))
const formHeaders = await new Promise((resolve, reject) => {
form.getLength((err, length) => {
if (err) {
return reject(err)
}
const headers = Object.assign({ 'Content-Length': length }, form.getHeaders())
resolve(headers)
})
})
var reqOpts = {
url: jsreportUrl + '/api/import',
method: 'POST',
body: form,
headers: {
'Authorization': 'Basic ' + jsreportAuthrization,
...formHeaders
}
}
request(reqOpts, function(err, result, body) {
console.log(err, body)
})
}
Thanks once again.