Forum Discussion

Neehar's avatar
Neehar
Helper I
4 years ago

PowerBIEntityNotFound - Microsoft.PowerBI.Api.V2.ExportReportWithHttpMessagesAsync

Hello,

 

I'm trying to copy the Power BI reports in the workspaces from one tenant to another tenant. 

 

I have used the service principal authentication for getting the token.

 

once I get the token I have followed the below steps.

 

Step 1

//Exporting the report into the memory stream.

MemoryStream destination = new MemoryStream();
powerbiclient.Reports.ExportReportWithHttpMessagesAsync(ReportId).Result.Body.CopyTo(destination);

 

Step 2

//converting to ByteArray

byte[] byteArray = destination.ToArray();

 

Step 3

//posting the byteArray  to the power bi API

https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/imports?datasetDisplayName={datasetDisplayName}

 

Everything was working fine in the dev environment.

 

But in the prod environment, I'm facing the issue in the step1 while exporting the report to the memory stream using 

ExportReportWithHttpMessagesAsync

 

It says 

{"error":{"code":"PowerBIEntityNotFound","pbi.error":{"code":"PowerBIEntityNotFound","parameters":{},"details":[],"exceptionCulprit":1}}}

 

Note that I have also given the below API permissions.

Dataset.Read.All
Dataset.ReadWrite.All
Report.Read.All
Report.ReadWrite.All

 

 

Please Help.

 

Thanks | Neehar