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
PKidd
Frequent Visitor

Power bi print endpoint stops each day - Operation returned an invalid status code 'Forbidden'

Hi all,

We get access to power bi printing endpoint in the morning and then it stops, it varies when it stops, it never fails when we run it from Visual Studio. 

The error is Operation returned an invalid status code 'Forbidden'.

 

Would really like to know if we are reaching a limit that we are not aware of.

 

Our customers have access to the reports on a continual basis, no problems.

We have ruled out our firewall rules.

We have a premium backed embedded service EM1 SKU.

We use a service principal account.

Fabric capacity metrics do not show any thresholds being exceeded ever.

The webapp runs in a secure network segment.

Embed Trial tokens is 0 but we have purchased an embedded SKU so don't see this is the issue

 

The code we use:

  public static MemoryStream ExportPowerBIReport(

      Guid WorkspaceId,

      Guid ReportId,

      string ExportName,

      FileFormat ExportFileFormat,

      string ExportFilter = "")

  {

            var exportRequest = new ExportReportRequest

            {

                Format = ExportFileFormat,

                PowerBIReportConfiguration = new PowerBIReportExportConfiguration

                {                  

                    DefaultBookmark = new PageBookmark {State = ExportFilter }

                },

            };

 

   Export export = pbiClient.Reports.ExportToFileInGroup(WorkspaceId, ReportId, requestParameters: exportRequest);

          

            string exportId = export.Id;

 

   do

   {

    System.Threading.Thread.Sleep(5000);

    export = pbiClient.Reports.GetExportToFileStatusInGroup(WorkspaceId, ReportId, exportId);  

   } while (export.Status != ExportState.Succeeded && export.Status != ExportState.Failed); 

 

   if (export.Status == ExportState.Succeeded)

   {

        var exportStream = pbiClient.Reports.GetFileOfExportToFileInGroup(WorkspaceId, ReportId, exportId);

        var memoryStream = new MemoryStream();

        exportStream.CopyTo(memoryStream);

        return memoryStream;

   }

    return null;

  }

 

Thanks for any help

Paul

1 REPLY 1
AmosHersch
Employee
Employee

Hi @PKidd ,

Can you specify which of the requests gets the 'Forbidden' response? Is it always the 'ExportToFileInGroup' request or the request to 'GetExportToFileStatusInGroup'/'GetFileOfExportToFileInGroup' ? Did you check to see if the response body has additional details which might indicate the reason for the error response? You might need to capture the response with a tool like fiddler or trace the exception. The SDK will not show it to you AFAIK.

 

If you have an example of a request ID (from the response header) I might be able to help with finding the reason.

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.