Hi friend, how are you? I saw that your suggestion helped a colleague who needed help. I have a similar case and I've tried several alternatives, experimenting with different variations of the "Web.Contents", "Query", "Expression.Evaluate", "Text.FromBinary" functions, but I've had no success. I've looked for solutions in various videos, blogs (including Chris Webb's blog which covers some similar cases)... The code below is still considered to be a dynamic data source, which has greatly hindered the automatic updating of some reports. Can you help me identify the problem?
// EPNTV001 - VCAD_Project Base2
let
// Defina as credenciais
User = "marcella.piceli@promon.com.br",
Password = "Hg6qNqeAquH2S2TZjn8J",
// Função para obter o token
GetToken = () =>
let
token_url = "https://flounder-amusing-moderately.ngrok-free.app/get_token",
token_response = Json.Document(
Web.Contents(
token_url,
[
Content=Text.ToBinary("user=" & User & "&password=" & Password),
Headers=[#"Content-Type"="application/x-www-form-urlencoded"]
]
)
),
token = token_response[token]
in
token,
// Obtenha o token
token = GetToken(),
// Continue com a lógica de obtenção de arquivos
fn = "/get_file_content/",
root = "https://flounder-amusing-moderately.ngrok-free.app",
root_url = "https://flounder-amusing-moderately.ngrok-free.app/get_files",
root_source = Json.Document(
Web.Contents(
root_url,
[Query=[#"token"=token]]
)
),
filesTable = Table.FromList(root_source, Splitter.SplitByNothing()),
#"Column Expanded" = Table.ExpandRecordColumn(filesTable, "Column1", {"id", "name"}, {"fileId", "Nome do Arquivo"}),
// Filtrar a tabela para encontrar o fileId desejado
file = Table.SelectRows(#"Column Expanded", each Text.Contains([Nome do Arquivo], "EPTNV001 - VCAD_Project Base2")),
// Utilizar Expression.Evaluate com token na URL
file_source = Expression.Evaluate(
Text.FromBinary(
Web.Contents(
root & fn & file{0}[fileId] & "?token=" & token
)
),
#shared
)
in
file_source