Hi,
I am trying to export a report in .pbix format using the power bi rest api export endpoint(https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exportreportingroup). But, after downloading the file I am unable to open the file and receiving an error stating it is corrupt.
I have NodeJS Express API end point and here is the code
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) {
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 frontned is as RectJS application and here is the frontend code.
reqBody.tenantId = reportData.tenantId;
reqBody.workspaceId = reportData.workspaceId;
reqBody.reportId = reportData.reportId;
this.props.exportReport(reqBody).then(() =>{
console.log(self.props.exportReportObj);
var blobObj = new File([self.props.exportReportObj.exportReportData], dd.name+ ".pbix" );
FileSaver.saveAs(blobObj);
})
Can you please help me on this?