1
votes

I'm trying to build a component in an Angular application to embed reports.

Tech used:

  • Angular 8
  • ngx-powerbi npm package
  • PowerBI REST API
  • PowerBI Pro account

We are calling the Get Pages in Group endpoint, located here: https://docs.microsoft.com/en-us/rest/api/power-bi/reports/getpagesingroup

  • We have the workspace or group id in our config settings
  • We call the Get Reports in Group (passing this workspace). This will be used to populate a dropdown of Reports in the FE.
  • For each of the Report chosen we call the Get Pages in Group passing in the same workspace id and report id. These pages will be shown as a tabbed view material component (as opposed to using the default page selector on the Report)

What's happening is that there are "Hidden" pages in the Report in the app.powerbi.com workspace. When the pages for the report is retrieved, it's bringing all pages back, even those that are hidden.

These Pages are those that are old or a WIP and shouldn't be seen by the end user.

Is there any any to filter these in the PowerBI REST API endpoint linked above?

There only solutions I can see right now are:

  • Go back to using the default page/section tabs that are built in to the report (the users don't like this)
  • Prefix the "hidden" page names with something like "WIP -" and we can filter these out in our code. Seems a bit dirty to me.

Hopefully someone can help. :) Happy to add more information if neeed.

1

1 Answers

1
votes

You can use the visibility property of report pages and then filter pages accordingly.

Pages marked hidden have visibility property set to 1.

Please refer to below code snippet:

async function showPages() {
  // Use getPages API to get the list of pages
  pages = await report.getPages();

  for (let i=0; i < pages.length; i++) {

    // Check visibility property of the page object
    if (pages[i].visibility) {
      continue;
    }
      // Append page name to the dropdown
      $('#selectBox').append($('<option />').text(pages[i].displayName))
  }
}

Now, the hidden page would not be shown in the dropdown.

You can also refer to https://docs.microsoft.com/en-us/javascript/api/powerbi/powerbi-client/page.page#visibility