cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
albin-ipmg Frequent Visitor
Frequent Visitor

Power BI Embedded API - PostImportWithFile returns "Internal Server Error"

I am getting an exception (see below) returned by client.Imports.PostImportWithFile method when importing a fairly large PBIX file (approx. 700MB) to Azure workspace. The same does not happen with a smaller file of around 400 MB or less. After the exception is thrown for the larger file, I still end up with the PBIX file in the workspace but with multiple copies of the same report as if the import process was run several times. I also end up with multiple datasets. There are usually 4 identical copies of the large file which end up in the workspace after the exception is thrown. All multiple copies have different report id.

 

Any insight or ideas are greatly appreciated. Code is below for reference.

 

 

 

                using (var fileStream = File.OpenRead(filePath.Trim('"')))
                {
                    var import = client.Imports.PostImportWithFile(powerBiWorkspaceCollection.WorkspaceCollectionName, powerBiWorkspaceCollection.WorkspaceId, fileStream, datasetName);

                    while (import.ImportState != "Succeeded" && import.ImportState != "Failed")
                    {
                        import = client.Imports.GetImportById(powerBiWorkspaceCollection.WorkspaceCollectionName, powerBiWorkspaceCollection.WorkspaceId, import.Id);
                        System.Threading.Thread.Sleep(1000);
                    }

                    ...
                }

 

Operation returned an invalid status code 'InternalServerError'

at Microsoft.PowerBI.Api.V1.Imports.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerBI.Api.V1.ImportsExtensions.PostImportWithFile(IImports operations, String collectionName, String workspaceId, Stream fileStream, String datasetDisplayName, String nameConflict)
at Ipmg.InSightCore.Service.PowerBiService.d__15.MoveNext()
1 ACCEPTED SOLUTION

Accepted Solutions
albin-ipmg Frequent Visitor
Frequent Visitor

Re: Power BI Embedded API - PostImportWithFile returns "Internal Server Error"

For anyone with same issue, the problem is in using the base url https://api.powerbi.com. As per Microsoft support, when using this base url and importing large PBIX files, it has a tendency to timeout the file stream, thus throwing the exception. Microsoft support provided a direct URL to our local Power Bi Workspace cluster and the issue was resolved.

3 REPLIES 3
albin-ipmg Frequent Visitor
Frequent Visitor

Re: Power BI Embedded API - PostImportWithFile returns "Internal Server Error"

For anyone with same issue, the problem is in using the base url https://api.powerbi.com. As per Microsoft support, when using this base url and importing large PBIX files, it has a tendency to timeout the file stream, thus throwing the exception. Microsoft support provided a direct URL to our local Power Bi Workspace cluster and the issue was resolved.

Moderator Eric_Zhang
Moderator

Re: Power BI Embedded API - PostImportWithFile returns "Internal Server Error"


@albin-ipmg wrote:

For anyone with same issue, the problem is in using the base url https://api.powerbi.com. As per Microsoft support, when using this base url and importing large PBIX files, it has a tendency to timeout the file stream, thus throwing the exception. Microsoft support provided a direct URL to our local Power Bi Workspace cluster and the issue was resolved.


@albin-ipmg

Thanks for your sharing, you're awesome! Smiley LOL

Could you be more specific on the direct URL?

Highlighted
albin-ipmg Frequent Visitor
Frequent Visitor

Re: Power BI Embedded API - PostImportWithFile returns "Internal Server Error"

@Eric_Zhang,

 

Absolutely. When the workspace collections are created with the Azure dashboard, there is a choice of location to select (i.e. East US 2, West US 1, etc.). These are their clusters for Power BI workspace collections and they have direct API URLs to these clusters so instead of https://api.powerbi.com, one would use the direct URL to the Azure cluster location where your workspace collections are hosted. For my case scenario, we have all of our workspace collections hosted in the same cluster location so I just had to use the direct URL instead of https://api.powerbi.com and the filestream timeouts (including the vague Internal Server Error exception returned by the PostImportWithFile method) were gone. Just check with your Microsoft support rep for your Power BI cluster's direct URL if you have to import larger PBIX files.