Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Corrupt file or an invalid file : when trying to open downloaded pbix file using Power BI Rest API.

Hello,

 

I am unable to open .pbix file when downloaded using Power BI Rest API, I have use Export report from group endpoint to donload the file. 

 

I have NodeJS as backend handling the API request. 

 

daoObj.exportReportgroupIdreportIdtoken).then(function (status) {  
                      res.status(200).send(status);
}, function (error) {
             ocalogger.error(tenantId'>>> Error exporting report: ' + reportId + ': 'error);
            deferred.reject(error);
});
 
 exportReport: function ( groupIdreportIdaccessToken) {
        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 (errresponsebody) {
            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
0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.