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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Simple API - authenticaion error

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.

1 REPLY 1
Anonymous
Not applicable

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.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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