The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I'm working on a Power Query script in Excel to fetch data from the QGenda API. I'm encountering an error in the first part of my code, which is supposed to retrieve an authentication token.
I've already checked the following:
I'm not sure why Power Query thinks I'm trying to connect anonymously when I'm providing my credentials. Any help troubleshooting this would be greatly appreciated!"
The error I am receiving at this time is "DataSource.Error: Web.Contents with the Content option is only supported when connecting anonymously.
Details:
DataSourceKind=Web
DataSourcePath=https://api.qgenda.com/v2/login"
let
// Step 1: Get the Authentication Token
url_login = "https://api.qgenda.com/v2/login",
body = [
email = "emailaddress",
password = "password"
],
encodedBody = Text.ToBinary(Uri.BuildQueryString(body)),
response_login = Web.Contents(url_login, [
Headers = [
#"Content-Type" = "application/x-www-form-urlencoded"
],
Content = encodedBody
]),
jsonResponse = Json.Document(response_login),
accessToken = jsonResponse[access_token], // Or jsonResponse[accessToken] if that's the actual field name
// Store the access token in an Excel cell (with error handling)
StoreToken = try
Excel.CurrentWorkbook(){[Name="Qgenda_Token"]}[Content] = Table.FromRecords({[Token = accessToken]})
otherwise
error Error.Record("Excel Error", "Failed to store access token."),
// (Optional) Output the access token for verification
OutputToken = accessToken
in
OutputToken
Solved! Go to Solution.
Change your data source setting accordingly. You need to clear permissions as they are cached.
The error occurs because Web.Contents with Content requires a RelativePath. Use this fixed script:
let
base_url = "https://api.qgenda.com",
url_login = "/v2/login",
body = [
email = "emailaddress",
password = "password"
],
encodedBody = Text.ToBinary(Uri.BuildQueryString(body)),
response_login = Web.Contents(base_url, [
RelativePath = url_login,
Headers = [#"Content-Type" = "application/x-www-form-urlencoded"],
Content = encodedBody
]),
jsonResponse = Json.Document(response_login),
accessToken = jsonResponse[access_token],
OutputToken = accessToken
in
OutputToken
Hi @callahan_254 ,
May i ask if you have resolved your query. If yes, please mark the helpful reply as 'Accept as Solution' to help others with similar issues. If you need further assistance please reach out.
Thank you.
Hi @callahan_254 ,
We just wanted to check in again regarding your issue. If you’ve found a solution, marking the reply as the solution and leaving a kudos would be greatly appreciated, it helps the community and others with similar questions.
If you’re still facing challenges or have further questions, please let us know.
Thank you.
Hi @callahan_254 ,
We're following up to see if the solutions provided met your needs. If they did, please accept them as the solution to help others benefit. If you still need assistance, please don't hesitate to reach out. Thank you!
The error occurs because Web.Contents with Content requires a RelativePath. Use this fixed script:
let
base_url = "https://api.qgenda.com",
url_login = "/v2/login",
body = [
email = "emailaddress",
password = "password"
],
encodedBody = Text.ToBinary(Uri.BuildQueryString(body)),
response_login = Web.Contents(base_url, [
RelativePath = url_login,
Headers = [#"Content-Type" = "application/x-www-form-urlencoded"],
Content = encodedBody
]),
jsonResponse = Json.Document(response_login),
accessToken = jsonResponse[access_token],
OutputToken = accessToken
in
OutputToken
Hi @callahan_254 ,
Thank you for reaching out regarding the error you're encountering in Power Query while connecting to the QGenda API.
As recommended by @lbendlin , modifying the data source settings and clearing the cached permissions could help resolve the issue.
Clear Cached Permissions:
-As pointed out by the @lbendlin , go to Data > Get Data > Data Source Settings in Excel.Set the Correct Access Mode:
-When prompted by the Access Web Content dialog, choose the appropriate option:Re-Test the Connection:
-Once permissions are cleared and access settings are configured, run the script again to confirm resolution.Hope these steps help to resolve your issue.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and a kudos would be appreciated.
Best Regards.
Change your data source setting accordingly. You need to clear permissions as they are cached.