exportReport: function ( groupId, reportId, accessToken) {
var deferred = QRef.defer();
const url = config.apiRoot + 'groups/' + groupId + '/reports/' + reportId + '/Export';
const headers = {
'Authorization': 'Bearer ' + accessToken
};
request.get({ url: url, headers: headers}, function (err, response, body) {
if(response.statusCode === 200){
deferred.resolve(response.body);
}else{
if (err) {
deferred.reject(err);
} else if (parsedBody.error) {
deferred.reject(parsedBody.error.message);
} else {
// If successful, return the access token.
deferred.resolve(response.body);
}
}
});
return deferred.promise;
}
The front end is ReactJS and I am using "file-saver" npm package to download the file.
handleExportReportEvent = (reportData) =>{
var self = this;
var reqBody = {};
reqBody.workspaceId = reportData.workspaceId;
reqBody.reportId = reportData.reportId;
this.props.exportReport(reqBody).then(() =>{
var blobObj = new Blob([self.props.exportReportObj.exportReportData] );
FileSaver.saveAs(blobObj, "report.pbix");
})
}
I am able to download the file, but when I try to open with the latest Power BI Desktop application, I am receving
"The report.pbix file is corrupt or an invalid file".
Please let me know where I am making a mistake