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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ericOnline
Post Patron
Post Patron

How to create PBI API Authorization header from AppID and Secret?

I'm trying to use the PBI API to export reports to .png. I followed the docs to get an app registered in Azure and received an App ID and Secret. 

How do I create the Authorization header for API request using AppID and Secret?

The only examples I've been able to find all use C# or Java to create a "token". I don't have these tools at my disposal. Need an alternative, preferrably also using REST API of some sort. 

 

Thank you

1 ACCEPTED SOLUTION

I figured it out. My client_secret had both a "+" and a "=" in it. I had to use the Flow action of encodeUriComponent. 
Sweet!

View solution in original post

4 REPLIES 4
ericOnline
Post Patron
Post Patron

Following up here... the request I created above successfully returns a token, however the token is rejected when make a call to PowerBI REST API. 


Why could that be?

ericOnline
Post Patron
Post Patron

Thank you for the resources. I've read through them.

 

My challenge is trying to access the PBI REST API from outside PowerBI (from Power Automate in this case).  In the video example you shared, the person is using the Client_ID from their Azure registered app along with their own Username and Password to generate an access token. 

ericOnline_0-1614187592089.png

 

This will not work in my case. 

 

I need to generate a token with Client_ID and Client_Secret. How is this done?

ericOnline_1-1614278901086.png

The error I'm receiving is Invalid Client Secret (though I've checked and double checked that the secret is correct):

 

 

{
  "error": "invalid_client",
  "error_description": "AADSTS7000215: Invalid client secret is provided.\r\nTrace ID: 947ff77d-fc36-480d-a58c-011c126e7400\r\nCorrelation ID: 2af5df99-2ff6-41cb-a094-ca7d5750ef99\r\nTimestamp: 2021-02-24 17:30:39Z",
  "error_codes": [
    7000215
  ],
  "timestamp": "2021-02-24 17:30:39Z",
  "trace_id": "947ff77d-fc36-480d-a58c-011c126e7400",
  "correlation_id": "2af5df99-2ff6-41cb-a094-ca7d5750ef99",
  "error_uri": "https://login.microsoftonline.com/error?code=7000215"
}

 

I figured it out. My client_secret had both a "+" and a "=" in it. I had to use the Flow action of encodeUriComponent. 
Sweet!

v-lionel-msft
Community Support
Community Support

Hi @ericOnline ,

 

Please refer to the links.

How to Call Power BI Rest APIs from Power BI Desktop – Register your Power BI Application – Part One...

Call Power BI Rest API with Dynamic Access Token From Power BI Desktop |Power BI Rest API | Part Two...

v-lionel-msft_4-1614152462657.png

v-lionel-msft_1-1614152272409.png

v-lionel-msft_2-1614152324354.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.