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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
andra2
Helper I
Helper I

unable to retrieve workspaces data - REST API

Hello, 

 

I am trying to retrieve the existing workspaces within my PBI Tenant. For this I have created a function like this:

() =>
let
body = "grant_type=Password&resource=https://analysis.windows.net/powerbi/api&client_id=98xxxxxxxx&client_secret=lBxxxxx&username=xxxxx@x...",
Data=Json.Document(Web.Contents("https://login.microsoftonline.com/common/oauth2/token/", [Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
access_token = Data[access_token]
in
access_token.

 

Then I use this query to retrieve the data:

let
Source = Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/groups?$top=100", [Headers=[Authorization="Bearer "&GetAccessToken()]])),
value = Source[value],
#"Converted to Table" = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "isReadOnly", "isOnDedicatedCapacity", "name"}, {"id", "isReadOnly", "isOnDedicatedCapacity", "name"})
in
#"Expanded Column1"

 

but I am receiving this error. Do you know which might be the cause? Thank you very much!!

An error occurred in the ‘’ query. DataSource.Error: Web.Contents failed to get contents from 'https://login.microsoftonline.com/common/oauth2/token/' (400): Bad Request
Details:
DataSourceKind=Web
DataSourcePath=https://login.microsoftonline.com/common/oauth2/token
Url=https://login.microsoftonline.com/common/oauth2/token/

1 REPLY 1
v-janeyg-msft
Community Support
Community Support

Hi, @andra2 

 

Can you test if you can get access token in postman? 

You can check the doc:

Reference:Solved: Re: REST API Get Access Token - Microsoft Power BI Community
Handling authentication for Power Query connectors | Microsoft Docs

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.


Best Regards,

Community Support Team _ Janey

Helpful resources

Announcements
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.