Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I'm trying to connect to a Rest API from Sugar CRM (sugarcrm).
I'm using the example from Chris Coester; Get Data from Twitter API with Power Query
and I have updated the code slightly with info from Chris Webb; Using The RelativePath And Query Options With Web.Contents()
Part 1, getting the access token from the first api call works fine. But in the next step, when I try to access a page using the access token, I get the following error; We couldn't authenticate with the credentials provided
I'm using the Anonymous connection method to access web content, and I have visited File -> Options and Settings -> Data source settings and both tried to Clear All Permissions and also Edit the permissions to Anonymous
Here is my code:
let
root="https://xxx.sugaropencloud.eu",
relativepath = "/rest/v11_12/oauth2/token",
GetJsonAccess = Web.Contents(root,
[
RelativePath = relativepath,
Query=
[
grant_type="password",
client_id="sugar",
username="xxx",
password="xxx",
platform="powerbi"
],
Headers = [#"Content-Type"="application/x-www-form-urlencoded;charset=UTF-8"],
Content = Text.ToBinary("grant_type=password") //This needs to be here for some reaon..
]),
FormatAsJson = Json.Document(GetJsonAccess),
// Part 1 - Completed here
// Gets token from the Json response
AccessToken = FormatAsJson[access_token],
AccessTokenHeader = "bearer " & AccessToken,
relativepath_report = "/rest/v11_12/me",
// Uses the Twitter GET search/tweets method using the bearer token from the previous POST oauth2/token method
GetJsonReport = Web.Contents(root,
[
RelativePath = relativepath_report,
Headers =
[
#"Authorization"=AccessTokenHeader
]
])
in
GetJsonReport
The code above works fine if I stop after Part 1 (see comment in code), but when I run all of the code above, I get the following error message: We couldn't authenticate with the credentials provided. Please try again.
If I try to access the URL (https://xxx.sugaropencloud.eu/rest/v11_12/me) from a webbrowser (without the correct Acces-token) I get the following error message, so even if the token was wrong, I expect another error message from Power BI then the one from above..
{
"error": "need_login",
"error_message": "No valid authentication for user.",
"url": "https://sts.service.sugarcrm.com/oauth2/xxx",
"platform": "base"
}
I have managed to get it to work by using Postman (First getting an Access Token and then using it in another call)
Please note that I have replaced all sensitive information above, with xxx (Part of the URL, Username and Password)
Any help is much apreciated!
Thanks
Solved! Go to Solution.
Hi again!
I found the solution!!! With a lot of help from my friends!
It's a really small and annoying error.
This row:
AccessTokenHeader = "bearer " & AccessToken,should be replaced with this row:
AccessTokenHeader = "Bearer " & AccessToken,Do you see the difference? Bearer should start with a capital B
I hope this helps someone!
Hi again!
I found the solution!!! With a lot of help from my friends!
It's a really small and annoying error.
This row:
AccessTokenHeader = "bearer " & AccessToken,should be replaced with this row:
AccessTokenHeader = "Bearer " & AccessToken,Do you see the difference? Bearer should start with a capital B
I hope this helps someone!
Hi,
does your dataset refresh without errors when you publish your report to the Power BI service? I currently have a similar query but I get error 405 saying the method is not allowed or unable to combine data.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!