Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi
I am struggling to connect to a dataset through API.
A sample PBIX file was provided by the data host however the simple action of switching out the API keys fails connect.
extract here from the advanced editor
let
url = "https://api.workguru.io/api/ClientTokenAuth/Authenticate/api/client/v1/tokenauth",
body = "{ ""ApiKey"": ""YOUR_API_KEY_"", ""Secret"": ""YOUR__API_SECRET"" }",
tokenResponse = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] )),
AccessToken = tokenResponse[accessToken],
AccessTokenHeader = "Bearer " & AccessToken,
data_url = "https://api.workguru.io/api/services/app/ClientPivotReport/GetAllActivityLinesInPeriod?start=01/01/2...",
data_body = "{
""authorization"": """& AccessTokenHeader & """,
""content-type"": ""application/json""
}",
GetGroups = Json.Document(
Web.Contents(
data_url,
[
Headers = Json.Document(data_body)
]
)
),
categories = GetGroups[result],
#"Converted to Table" = Table.FromList(categories, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"SourceDocNo", "SourceDocName", "Project", "Source", "Quantity", "Item", "UnitCost", "UnitPrice", "Client", "ClientId", "BillingClient", "Code", "Supplier", "Cost", "Revenue", "Profit", "GP", "Document", "ReportingCategory1", "ReportingCategory2", "OwnerOrManager", "CustomFieldValues", "Region", "ProductCategory", "Date", "Year", "Day", "Month", "Qtr"}, {"SourceDocNo", "SourceDocName", "Project", "Source", "Quantity", "Item", "UnitCost", "UnitPrice", "Client", "ClientId", "BillingClient", "Code", "Supplier", "Cost", "Revenue", "Profit", "GP", "Document", "ReportingCategory1", "ReportingCategory2", "OwnerOrManager", "CustomFieldValues", "Region", "ProductCategory", "Date", "Year", "Day", "Month", "Qtr"})
in
#"Expanded Column1"
My ammendment.
body = "{ ""ApiKey"": ""123456789"", ""Secret"": ""123456789"" }",
The error I get is "We couldn't authenticate with the credentials provided. Please try again." but I have confirmed the credentials are correct.
Hi @Anonymous
Please check that.
1.The body of getting access token is right, it may be affected by the token.
2.Please make sure your token is not expired, the token often have one-hour lifetime, if the token is expired, you need to get the token again.
and you can refer to the following link.
Solved: Pull data from a REST API Authentication - Microsoft Fabric Community
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.