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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Amar-Agnihotri
Resolver I
Resolver I

Invalid Grant error while accessing POST request for Power BI Rest API .

Hi ,

 I am trying to generate access token to access data through PBI API. I am using grant_type = authorization_code. I am following each and every step given in the below article - 

https://www.sqlshack.com/how-to-access-power-bi-rest-apis-programmatically/

I have registered my app in Azure AD and have taken all the necessary permissions -

API.png

 

AmarAgnihotri_1-1643960473241.png

AmarAgnihotri_2-1643960547703.png

 

AmarAgnihotri_3-1643960596128.png

AmarAgnihotri_4-1643960627025.png

 

 

AmarAgnihotri_5-1643960723953.png

 

What i believe that all necessary permissions have been granted to the application.
I have a Power BI administrator credentials

 

I am trying to check the API in postman as below -

 

API-1.png

 

But getting this error -

 

AmarAgnihotri_6-1643960999319.png

 

I am not able to understand how to resolve it. Can anybody help me out. 

 

I shall be thankful in advance. 

 

 

 

 

 

 

 

2 ACCEPTED SOLUTIONS
V-lianl-msft
Community Support
Community Support

Hi @Amar-Agnihotri ,

 

According to your description, you are calling Power BI REST API From Postman.

Did you add a Client Secret that will be displayed as the Value (not the Secret ID) in the Client Secrets section?

To set Postman up for use with various kinds of requests that you will be mailing off, set up Environment variables and Collections. (You can read up on Collections and Environment and other facilities in the documentation.)

For more details, please refer to :

https://www.csgpro.com/blog/power-bi-rest-apis/ 

 

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

View solution in original post

Amar-Agnihotri
Resolver I
Resolver I

Hello,

I made few changes in API call and the result is achieved -

 

See the changes in POST Request -

 

API-Changes.png

 

By this way we can get access token using Authorization Code

 

To know all about the authorization code from scratch click this link-

https://www.sqlshack.com/how-to-access-power-bi-rest-apis-programmatically/

 

There is way using id and password also to call REST API but that methode will never be preferred. Always try to follow the Authorization code method.

 

To know more about creating an admin panel follow this BI ELITE link -

 

https://www.youtube.com/watch?v=cTqFNg_y9lw&list=PLL-WSn9hvefogtxxi7CJhjLCJvrDY0mpQ

 

 

 

View solution in original post

5 REPLIES 5
Amar-Agnihotri
Resolver I
Resolver I

Hello,

I made few changes in API call and the result is achieved -

 

See the changes in POST Request -

 

API-Changes.png

 

By this way we can get access token using Authorization Code

 

To know all about the authorization code from scratch click this link-

https://www.sqlshack.com/how-to-access-power-bi-rest-apis-programmatically/

 

There is way using id and password also to call REST API but that methode will never be preferred. Always try to follow the Authorization code method.

 

To know more about creating an admin panel follow this BI ELITE link -

 

https://www.youtube.com/watch?v=cTqFNg_y9lw&list=PLL-WSn9hvefogtxxi7CJhjLCJvrDY0mpQ

 

 

 

V-lianl-msft
Community Support
Community Support

Hi @Amar-Agnihotri ,

 

According to your description, you are calling Power BI REST API From Postman.

Did you add a Client Secret that will be displayed as the Value (not the Secret ID) in the Client Secrets section?

To set Postman up for use with various kinds of requests that you will be mailing off, set up Environment variables and Collections. (You can read up on Collections and Environment and other facilities in the documentation.)

For more details, please refer to :

https://www.csgpro.com/blog/power-bi-rest-apis/ 

 

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

Hi @V-lianl-msft . I have added a client secret value. Yeah i have tried it via creating enviornment  variables also and it worked . Also your post is helpful to achive this so i am accepting it as a solution.

 

Thanks 😊

I have also used custome connector . That is working fine in PBI desktop when when i tried to refresh dataset in PBI service it throws an error - 

 

Custom-Connector Error.png

 

Also searching solution for this.

You can see here that i have already added a client secret 

 

AmarAgnihotri_0-1644214811973.png

 

API-1.png

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.