Forum Discussion
callahan_254
1 year agoNew 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 al...
- 1 year ago
Change your data source setting accordingly. You need to clear permissions as they are cached.
- 1 year ago
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
1 year agoHi 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.
-Locate the entry for https://api.qgenda.com/v2/login or https://api.qgenda.com.
-Select it and click Clear Permissions. -
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,
- 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. - 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. -
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.