1. Configure a consulta
A chave fica apenas no seu navegador — ela nunca é enviada nem armazenada por este portal.
2. Copie o código M
let
ApiKeyValue = "COLE_SUA_CHAVE_AQUI",
BaseUrl = "https://claude-data-hub.lovable.app",
PageSize = 1000,
// Filtros opcionais. Record vazio = sem filtro.
FiltroBase = [],
FetchPage = (offset as number) as record =>
let
Consulta = Record.Combine({
FiltroBase,
[
limit = Number.ToText(PageSize),
offset = Number.ToText(offset)
]
}),
Resposta = Web.Contents(
BaseUrl,
[
RelativePath = "api/public/assessor",
Query = Consulta,
Headers = [ #"x-api-key" = ApiKeyValue ]
]
)
in
Json.Document(Resposta),
PrimeiraPagina = FetchPage(0),
// Falha explícita se a resposta não trouxer o total de linhas.
TotalBruto = Record.FieldOrDefault(PrimeiraPagina, "count", null),
Total =
if TotalBruto = null or not Value.Is(TotalBruto, type number)
then error "Resposta sem o campo 'count'. Verifique a chave de API (header x-api-key) e a URL do endpoint."
else TotalBruto,
OffsetsRestantes =
if Total <= PageSize
then {}
else List.Generate(() => PageSize, each _ < Total, each _ + PageSize),
PaginasRestantes = List.Transform(OffsetsRestantes, each FetchPage(_)[data]),
TodasAsLinhas = List.Combine({ PrimeiraPagina[data] } & PaginasRestantes),
Colunas = { "id", "ticket_numero", "assunto", "status", "categoria", "subcategoria", "cliente", "solicitante", "responsavel", "data_abertura", "data_atualizacao", "data_fechamento", "tempo_gasto_horas", "tempo_contratado_horas", "mes_abertura", "mes_fechamento", "servico_completo", "urgencia", "justificativa", "quantidade_acoes" },
TabelaBruta = Table.FromRecords(TodasAsLinhas, Colunas, MissingField.UseNull),
TabelaTipada = Table.TransformColumnTypes(TabelaBruta, {
{"id", type text},
{"ticket_numero", type text},
{"assunto", type nullable text},
{"status", type nullable text},
{"categoria", type nullable text},
{"subcategoria", type nullable text},
{"cliente", type nullable text},
{"solicitante", type nullable text},
{"responsavel", type nullable text},
{"data_abertura", type nullable datetimezone},
{"data_atualizacao", type nullable datetimezone},
{"data_fechamento", type nullable datetimezone},
{"tempo_gasto_horas", type nullable number},
{"tempo_contratado_horas", type nullable number},
{"mes_abertura", Int64.Type},
{"mes_fechamento", type nullable number},
{"servico_completo", type nullable text},
{"urgencia", type nullable text},
{"justificativa", type nullable text},
{"quantidade_acoes", type nullable number}
})
in
TabelaTipada3. Cole no Power BI Desktop
- No Power BI Desktop: Página Inicial → Obter Dados → Consulta em Branco.
- No Editor do Power Query: Página Inicial → Editor Avançado, apague o conteúdo e cole o código acima.
- No prompt de credenciais, escolha Anônimo para o domínio
https://claude-data-hub.lovable.app. A credencial é definida por domínio — a chave viaja no headerx-api-key, e não na credencial. - Clique em Fechar e Aplicar.
Publicando no Power BI Service
Depois de publicar o relatório, abra as configurações do conjunto de dados no Serviço e configure novamente as credenciais da fonte de dados como Anônimo — sem isso, a atualização agendada falha. A chave continua embutida no código M da consulta.
Por que o código usa RelativePath
A URL nunca é montada por concatenação: o endereço base vai em Web.Contents e o caminho em RelativePath. Isso evita que o Power BI trate a consulta como fonte dinâmica e bloqueie a atualização no Serviço/Gateway.