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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. 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
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.

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.

March Power BI Update Carousel

Power BI Community Update - March 2026

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