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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
callahan_254
New Member

Power Query REST API error

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 using the correct email and password.
  • The url_login is accurate.
  • The Content-Type header is set correctly.

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

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Change your data source setting accordingly.  You need to clear permissions as they are cached.

 

lbendlin_0-1736873664877.png

 

View solution in original post

rohit1991
Super User
Super User

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

 

View solution in original post

6 REPLIES 6
v-veshwara-msft
Community Support
Community Support

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.

 

v-veshwara-msft
Community Support
Community Support

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.

v-veshwara-msft
Community Support
Community Support

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!

rohit1991
Super User
Super User

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

 

v-veshwara-msft
Community Support
Community Support

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.

  1. Clear Cached Permissions:

    -As pointed out by the @lbendlin , go to Data > Get Data > Data Source Settings in Excel.
    -Locate the entry for https://api.qgenda.com/v2/login or https://api.qgenda.com.
    -Select it and click Clear Permissions.
  2. Set the Correct Access Mode:

    -When prompted by the Access Web Content dialog, choose the appropriate option:
    -Anonymous if your script handles authentication (e.g., sending email and password in the request body).
    -Web API if you need to provide an API key or token directly.

    Additionally,
  1. Confirm Authentication Method:
    -Verify if the QGenda API requires additional headers like Authorization or a specific Bearer Token. Sometimes APIs may require credentials to be sent through headers, even if the body contains the username and password.
  2. Test with an External Tool (e.g., Postman):
    -If you're still having trouble, you can test the login request in an external tool like Postman. This will help you confirm if the API is behaving as expected and the issue is with the Power Query configuration.
  3. 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.

lbendlin
Super User
Super User

Change your data source setting accordingly.  You need to clear permissions as they are cached.

 

lbendlin_0-1736873664877.png

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.