Forum Discussion
Power BI Dayforce API Connection Fails with "We Couldn't Authenticate with the Credentials Provided"
I created a blank query in Power BI and am trying to retrieve data from the Dayforce API using the following M code:
let
BaseUrl = "https://can261-services.dayforcehcm.com/api/{CompanyID}/V1",
TokenUrl = "https://dfid.dayforcehcm.com/connect/token",
TokenResponse =
Json.Document(
Web.Contents(
TokenUrl,
[
Headers = [
#"Content-Type" = "application/x-www-form-urlencoded"
],
Content = Text.ToBinary(
Uri.BuildQueryString([
grant_type = "password",
companyId = CompanyID,
username = username,
password = password,
client_id = "Dayforce.HCMAnywhere.Client"
])
)
]
)
),
AccessToken = TokenResponse[access_token],
ReportResponse =
Json.Document(
Web.Contents(
BaseUrl & "/Reports/{ReportXRefCode}",
[
Headers = [
Authorization = "Bearer " & AccessToken
]
]
)
),
DataList = ReportResponse[Data]{0}[Rows],
ToTable = Table.FromRecords(DataList)
in
ToTableThe issue I'm encountering is that Power BI prompts me to edit credentials for the following URL:
https://can261-services.dayforcehcm.com/
Since the bearer token is being generated within the query, the authentication method I should select in the credential dialog is Anonymous. However, when I do that, I receive the following error:
"We couldn't authenticate with the credentials provided. Please try again."
My questions are:
- How can I fix this authentication error and why am I getting this?
- I get all the information when I run a similar query in Python in my VSCode, so I know that the steps are correct. I just need help in making it work in Power Query in Power BI.
Has anyone successfully connected to the Dayforce API from Power BI using this approach?
Any guidance or working examples would be greatly appreciated.
Power BI often struggles with APIs that generate tokens inside the query. Make sure all saved credentials for the Dayforce URLs are cleared and reconfigured as Anonymous, then test whether the token request succeeds before calling the report endpoint. If the token is being returned correctly, the issue is likely with how Power Query validates the second URL. Sharing the exact error details or status code would help narrow it down.
1 Reply
- jasonmiller11ttHelper II
Power BI often struggles with APIs that generate tokens inside the query. Make sure all saved credentials for the Dayforce URLs are cleared and reconfigured as Anonymous, then test whether the token request succeeds before calling the report endpoint. If the token is being returned correctly, the issue is likely with how Power Query validates the second URL. Sharing the exact error details or status code would help narrow it down.