Forum Discussion

callahan_254's avatar
callahan_254
New Member
1 year ago
Solved

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...
  • lbendlin's avatar
    1 year ago

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

     

     

  • rohit1991's avatar
    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