Forum Discussion
Connect to API through Power Query doesn´t work, but does in Power Automate
- 1 year ago
Hi Hamp79,
As trouble shooting steps doesn’t resolve your issue, we recommend raising a support ticket with Microsoft for further assistance.
To raise a support ticket for Fabric and Power BI, kindly follow the steps outlined in the following guide:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
If this post helps, please give us Kudos and consider marking it Accept as solution to assist other members in finding it more easily.
Thank you for being a part of Microsoft Fabric Community Forum!
I am able to get all of my org data with the given power query. Hope it might help you.
let // Define API details
tokenUrl = "https://",
apiUrl = "https://",
TokenBody = [
grant_type = "client_credentials",
client_Id = " ",
client_Secret = " "
],
// Get access token
tokenResponse = Json.Document(Web.Contents(tokenUrl,
[
Content = Text.ToBinary(Uri.BuildQueryString(TokenBody)),
Headers = [
#"Content-Type" = "application/x-www-form-urlencoded"
],
ManualStatusHandling = {400, 401, 403}
]
)),
accessToken = if Record.HasFields(tokenResponse, "access_token") then tokenResponse[access_token] else error "Failed to get access token",
// Call API with the access token
apiResponse = Web.Contents(apiUrl,
[Headers = [
#"ST-App-Key" = " ",
Authorization = "Bearer "& accessToken]]),
json = Json.Document(apiResponse),
BusinesUnitList = if Record.HasFields(json, "data") then json[data] else error "No data field found",
// Convert to table
Table = Table.FromList(BusinesUnitList, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
Table