Quantcast
Channel: Service topics
Viewing all articles
Browse latest Browse all 61727

Export report to pbix file - Power BI Rest API

$
0
0

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 ( 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 (errresponse) {
            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?

Viewing all articles
Browse latest Browse all 61727

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>