Forum Discussion
guigagliardi
3 years agoNew Member
Variable Token unnable to schedule refresh in Power Bi Service
I've been struggling with this API for a few days, where it needs to be executed in two steps:
- POST request to generate the Token, which is updated every 1 hour.
- GET request to fetch the content from the API.
When I run it in the Desktop, I have no problems getting the results. However, when I try to turn it into a Data Flow, I start receiving the following error:
(
It's not possible to save the data flow.
One or more tables reference a dynamic data source)
.
When building it step by step, for the 1st step, the Service allows me to save. But when I execute the second step, that's where my problem lies. Below, I'll insert the codes.
Step 1
let
urltk = url_,
cabecalhotk = [
#"Accept"= "application/x-www-form-urlencoded",
#"Content-Type"="application/x-www-form-urlencoded"
],
corpotk = [
grant_type = "password",
client_id = client_id_,
client_secret = client_secret_,
username = username_,
password = password_
],
corpoString = Uri.BuildQueryString(corpotk),
corpoBinario = Text.ToBinary(corpoString),
tokenResponse = Json.Document(
Web.Contents(
urltk,
[Headers = cabecalhotk, Content = corpoBinario]
)
),
Token1 = tokenResponse[access_token]
in
Token1
Step 2
let
url = url_api,
tokentexto = Json.FromValue(Token),
tokenconverte = Json.Document(tokentexto),
cabecalho = [
Accept = "application/json",
Authorization = "Bearer " & Token
],
FilterCriteriaAPI = [
page = "1",
pub_date_after = "2023-07-24",
pub_date_before = "2023-07-24"
],
queryStringAPI = Uri.BuildQueryString(FilterCriteriaAPI),
urlCompletaAPI = url & "?" & queryStringAPI,
responseAPI = Json.Document(Web.Contents(urlCompletaAPI, [Headers = cabecalho])),
resultado = responseAPI[results],
tabela = Table.FromRecords(resultado)
in
tabela
I don't know what else to do, I tried to apply the RelativePath, but for some reason, it cannot be accepted in Header's parameter.
Thanks
No RepliesBe the first to reply