let tokenApiUrl = "https://identity.leavewizard.com/connect/token", clientId = "cp1sQ6F2m0ofmXc6ngqc0", clientSecret = "sQ37H8QxZNm8KRAKMs47RkNl79sxJHs", scope = "lw-public-api", grantType = "client_credentials", apiUrl = "https://api.leavewizard.com/public/v1/events?from=2022-01-01T00:00:00.000Z&to=2024-12-31T00:00:00.000Z&status=approved|expired|NotApproved|Rejected|Expired", requestBody = [ #"client_id" = clientId, #"client_secret" = clientSecret, #"scope" = scope, #"grant_type" = grantType ], requestBodyEncoded = Uri.BuildQueryString(requestBody), apiResponse = Json.Document(Web.Contents(tokenApiUrl, [ Content = Text.ToBinary(requestBodyEncoded), Headers = [#"Content-Type" = "application/x-www-form-urlencoded"], ManualStatusHandling = {400, 401, 403, 404, 500} ])), // Ensure that apiResponse is a record with the expected properties tokenType = apiResponse[token_type], accessToken = apiResponse[access_token], Source = Json.Document(Web.Contents(apiUrl, [Headers=[Authorization= tokenType & " " & accessToken]])), #"Converted to Table" = Table.FromRecords({Source}), #"items" = Table.ExpandListColumn(#"Converted to Table", "items") in #"items"