Skip to main content
Showing results for 
Search instead for 
Did you mean: 

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply

Issues with Power BI API Permissions for Exporting Reports to PDF Using Azure AD App

Hi everyone,

I’m trying to automate the process of exporting Power BI reports to PDF using the Power BI REST API. I’ve registered an app in Azure AD and am using the Client Credentials flow to authenticate. However, I’m facing several issues, and I’m not sure how to resolve them:

Token Permissions Issue:
The token generated using the Client ID, Client Secret, and Tenant ID does not seem to have the required permissions. When I try to export a report, I get the following error:

API is not accessible for application


I’ve already added the following permissions to the app in Azure AD under API Permissions:

Dataset.ReadWrite.All
Report.ReadWrite.All
Workspace.ReadWrite.All
I also clicked Grant admin consent, but the issue persists. When I decode the token on jwt.ms, the scp (scopes) claim does not include these permissions.

Export to PDF Error:
When I try to export a report to PDF, I get the error:

The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object

I’m using the responseType: 'arraybuffer' option in my API call, and I’m saving the response using fs.writeFileSync. I suspect this might be related to the token permissions issue.

Using a Service Account:
I can successfully export reports when logged into the Power BI portal using my service account. However, I want to automate this process without manual intervention. Is there a way to use the service account credentials directly in the script, or do I need to rely on the Azure AD app?

Azure Portal Configuration:
The Azure Portal interface seems to have changed, and I’m not sure if I’m missing any steps in configuring the app. Could someone provide updated instructions for setting up an Azure AD app with the correct permissions for Power BI?

Here’s a summary of my setup:

Client ID: Registered in Azure AD.
Client Secret: Created and valid.
Tenant ID: Correctly configured.
Power BI API Calls: Using axios in Node.js to call the REST API.
Any guidance on how to resolve these issues would be greatly appreciated. I’m stuck and not sure what else to try.

{
  "typ": "JWT",
  "alg": "RS256",
  "x5t": "CNv0OI3RwqlHFEVnaoMAshCH2XE",
  "kid": "CNv0OI3RwqlHFEVnaoMAshCH2XE"
}.{
  "iss": "xxx",
  "iat": 1745612098,
  "nbf": 1745612098,
  "exp": 1745615998,
  "aio": "k2RgYHheyV5UrcN2Qd/n0OSKoFcmAA==",
  "appid": "xxx",
  "appidacr": "1",
  "idp": "xxx",
  "idtyp": "app",
  "oid": "xxx",
  "rh": "1.AVkA7qbazHqcDkOUl_IOUxg1gwkAAAAAAAAAwAAAAAAAAABZAABZAA.",
  "roles": [
    "Tenant.ReadWrite.All",
    "Tenant.Read.All"
  ],
  "sub": "4d28a243-42f0-449e-ba83-3adac80487ee",
  "tid": "ccdaa6ee-9c7a-430e-9497-f20e53183583",
  "uti": "3Qh2PqKplkqffhtKNbpSAA",
  "ver": "1.0",
  "xms_idrel": "7 30",
  "xms_rd": "0.42LlYBJijAQA"
}.[Signature]

Thank you in advance for your help!
1 REPLY 1

@Pondwar 

Are you sure your service principal has permissions to run the API?

1. Have you enabled required tenant settings to run the APIs and to run APIs using service principles. You have to add your SPN to a security group and add that security group under this setting under admin. portal in order to endable it 

Screenshot 2025-04-27 at 11.31.31 AM.png

2. Have you added the SPN to the workspace? if not then add that SPN to the workspace and then run the API call

3. Follow the microsoft documentation in order to check if there is any syntactical errors in your API call.

 

Adding permissions from the AZURE portal is not enough and it is not required if it is standalone appplication permissions and those are managed through tenant admin portal

 

Need a Power BI Consultation? Hire me on Upwork

 

 

 

Connect on LinkedIn

 

 

 








Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!


PBI_SuperUser_Rank@2x.png

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors
Users online (2,976)
  • Olashileayomi
  • danextian
  • data-marty
  • AllisonKennedy
  • persepta
  • GilbertQ
  • sql-troubles23
  • Power2G
  • stribor45
  • shipsides
  • SundarRaj
  • ics_sys_usr
  • NROBBIANO
  • dcheng029
  • tsosa121
  • ashmitp869
  • maj07msu
  • clongwell
  • DeanTCC
  • Starlynk
  • RollingRock2315
close