Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Generating Token Dynamically from Power BI Desktop

I am trying to generate REST API token dynamically from Power BI Desktop, using power Query.   I am not sure what is causing this error. Any help is appreciated. An error occurred in the ‘’ query. D...
  • Anonymous's avatar
    Anonymous
    1 year ago

    After making few minor changes the code is generating token in Power BI . here is the modified code

    let
    GenerateToken = () =>
    let
    url = "https://login.mypurecloud.com.au/oauth/token",
    body = "grant_type=client_credentials&client_id=<client-id>&client_secret=<Clinet_secret>",
    headers = [#"Content-Type" = "application/x-www-form-urlencoded"],
    response = Web.Contents(url, [Headers = headers, Content = Text.ToBinary(body)]),
    jsonResponse = Json.Document(response),
    accessToken = jsonResponse[access_token]
    in
    accessToken
    in
    GenerateToken