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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
ayazbedrekar
New Member

Get Access Token

 

As per below video , need to update the token every 1 hour & write the query accordinlgy but 
https://www.youtube.com/watch?v=cTqFNg_y9lw&list=PLL-WSn9hvefogtxxi7CJhjLCJvrDY0mpQ 

But In blank query :  Get access token.

********************************************************************************************************
let
body = "grant_type=password&resource=https://analysis.windows.net/powrebi/api&client_id=ourTenantId&username=abc@xyz.com&password=abcd",
Data= Web.Contents("https://login.microsoftonline.com/common/oauth2/token/",
[
Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(body)


])

in
Data
******************************************************************************************************************
 we are getting problem with trying to access data from API service & getting below error.
DataSource.Error: Web.Contents failed to get contents from (400): Bad Request

so request you please let me know is there any change in query, resource link or web link or script? Could you help me build this function or share some example?

please findbelow screen shot.

 

ayazbedrekar_0-1646996598135.png

 

 

already gone throgh below links:

 

https://community.powerbi.com/t5/Developer/REST-API-Get-Access-Token/m-p/1895937#M29924 

https://community.powerbi.com/t5/Developer/Power-BI-REST-API-using-postman-generate-embed-token/m-p/... 

2 REPLIES 2
Anonymous
Not applicable

Hi @ayazbedrekar ,

 

Any updates?

 

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

Hi @ayazbedrekar ,

 

Below is an answer provided in a similar thread, please refer to

Eyelyn9_0-1647235938455.png

 

And there is are serveral links posts on Web.Contents() / how to connect to REST API via OAuth2 in Power BI. Please check if these could help you a little.

https://chris.koester.io/index.php/2015/07/16/get-data-from-twitter-api-with-power-query/

400: Bad Request in Power Query RRS feed 

Web.Contents(), M Functions And Dataset Refresh Errors In Power BI 

 

If you still get error, you can use Fiddler to track the process following the guide in this video.

 

 

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

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors