Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
emerson89
Helper I
Helper I

Error AccessForbinddenException to Refresh data

Hi,

 

I use a query by calling another query, via API and I'm not able to update the data in Power BI.

In Power Query it works normally, but for that, so that in Power Query I could run the "query from the query" I had to make the following changes to my project:

 

1 - Clear the Global Permissions and local permissions in Datasource configuration.

2 - Datasource Configuration >> Edit Permissions: I changed to privacy level: none and Credencials: none

3 - In the menu Options >> Privacy, I checked the item: "always ignore privacy level settings"

 

Changing the items above, in Power Query, my query works correctly. However, when trying to Apply these changes to the Panel, I get the following error message:

 

erro.png

 

- My query lists about 30 thousand rows, and I noticed that if I limit my query to half the data, it works normally without the above error, in the dashboard panel, updating the data correctly.
My question is whether there are any data limit limitations for loading on the panel? And if so, how can I solve this problem?
If it is not a limitation of lines in loading, what could be happening so that my panel is not updated?

 

My Query:

let
    ufnCallAPI = (numPedido) =>

        let
            result = Json.Document(Web.Contents("https://api.vhsys.com/", [RelativePath="v2/pedidos/" & Number.ToText(numPedido)  & "/produtos", 
             Headers=[#"access-token"="OCKNYbAMaDgLBZBSQPCOGPWOXGSbdO", #"secret-access-token"="xxxxxxxx"]]))  
        in
            result,

        pageRange = listaPedidos_Aquiles2, /* MY OTHER QUERY */
        pages = List.Transform(pageRange, each ufnCallAPI(_)),
    pages2 = Table.FromList(pages, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    pages3 = Table.ExpandRecordColumn(pages2, "Column1", {"code", "status", "data"}, {"code", "status", "data"}),
    pages4 = Table.ExpandListColumn(pages3, "data"),
    pages5 = Table.RemoveColumns(pages4,{"code", "status"}),
    #"data Expandido" = Table.ExpandRecordColumn(pages5, "data", {"id_ped_produto", "id_pedido", "id_produto", "desc_produto", "qtde_produto", "desconto_produto", "ipi_produto", "icms_produto", "valor_unit_produto", "valor_custo_produto", "valor_total_produto", "valor_desconto", "peso_produto", "peso_liq_produto", "info_adicional", "xPed_produto", "nItem_produto"}, {"id_ped_produto", "id_pedido", "id_produto", "desc_produto", "qtde_produto", "desconto_produto", "ipi_produto", "icms_produto", "valor_unit_produto", "valor_custo_produto", "valor_total_produto", "valor_desconto", "peso_produto", "peso_liq_produto", "info_adicional", "xPed_produto", "nItem_produto"}),
    #"Personalização Adicionada" = Table.AddColumn(#"data Expandido", "Empresa", each "Aquiles")
in
    #"Personalização Adicionada"

 

Thank you very much!

4 REPLIES 4
camargos88
Community Champion
Community Champion

Hi @emerson89 ,

 

Are you paginating it ? Try running it with 1 or 2 pages, just to check if you get this error.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Hi @camargos88 ,


Yes, My query listaPedidosAquiles is paginate, but, alone, this work fine. I tested it by dividing the page quantity in half, and it worked fine. I tested it on 4 pages too, for example, and everything works normally. The problem occurs when I try to list all data. Any idea?

Thanks

 

@emerson89 ,

 

I suspect the code tries to get more pages than the amount available.

How are you defining the amount of pages ?



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Hi @camargos88 ,

 

Really, your observation makes sense, however, when I run the query I use to separate the numbers (requests) to be used as a parameter for the second query, it works perfectly.

 

Here is my first query:

let
    ufnCallAPI = (nPage) =>
        let
            result = Json.Document(Web.Contents("https://api.vhsys.com/", [RelativePath="v2/pedidos?offset=" & Number.ToText(nPage) & "&limit=250&status=Atendido", 
            Headers=[#"access-token"="OCKNYbAMaDgLBZBSQPCOGPWOXGSbdO", #"secret-access-token"="xxxxxxxxx"]]))  
        in
            result,

        tmpResult = ufnCallAPI(1),

        auxTotal1 = Record.ToTable(tmpResult),
        Value = auxTotal1{2}[Value],
        auxTotal2 = Value[total],

        totalItems = auxTotal2,
        pageRange = {0..Number.RoundUp(totalItems / 250)-1},
        aux = List.Transform(pageRange, each ufnCallAPI(_*250)),
        aux2 = Table.FromList(aux, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        aux3 = Table.ExpandRecordColumn(aux2, "Column1", {"code", "status", "paging", "data"}, {"Column1.code", "Column1.status", "Column1.paging", "Column1.data"}),
        aux4 = Table.ExpandListColumn(aux3, "Column1.data"),
        aux5 = Table.RemoveColumns(aux4,{"Column1.code", "Column1.status", "Column1.paging"}),
        aux6 = Table.ExpandRecordColumn(aux5, "Column1.data", {"id_ped", "id_pedido", "id_cliente", "nome_cliente", "id_local_retirada", "id_local_cobranca", "vendedor_pedido", "vendedor_pedido_id", "listapreco_produtos", "valor_total_produtos", "desconto_pedido", "desconto_pedido_porc", "peso_total_nota", "peso_total_nota_liq", "frete_pedido", "valor_total_nota", "valor_baseICMS", "valor_ICMS", "valor_baseST", "valor_ST", "valor_IPI", "condicao_pagamento_id", "condicao_pagamento", "frete_por_pedido", "transportadora_pedido", "id_transportadora", "data_pedido", "prazo_entrega", "referencia_pedido", "obs_pedido", "obs_interno_pedido", "status_pedido", "contas_pedido", "comissao_pedido", "estoque_pedido", "ordemc_emitido", "data_cad_pedido", "data_mod_pedido", "id_aplicativo", "id_pedido_aplicativo", "lixeira"}, {"id_ped", "id_pedido", "id_cliente", "nome_cliente", "id_local_retirada", "id_local_cobranca", "vendedor_pedido", "vendedor_pedido_id", "listapreco_produtos", "valor_total_produtos", "desconto_pedido", "desconto_pedido_porc", "peso_total_nota", "peso_total_nota_liq", "frete_pedido", "valor_total_nota", "valor_baseICMS", "valor_ICMS", "valor_baseST", "valor_ST", "valor_IPI", "condicao_pagamento_id", "condicao_pagamento", "frete_por_pedido", "transportadora_pedido", "id_transportadora", "data_pedido", "prazo_entrega", "referencia_pedido", "obs_pedido", "obs_interno_pedido", "status_pedido", "contas_pedido", "comissao_pedido", "estoque_pedido", "ordemc_emitido", "data_cad_pedido", "data_mod_pedido", "id_aplicativo", "id_pedido_aplicativo", "lixeira"}),
        listPedidos = aux6[id_ped]
in
    listPedidos

 

This code returns a list for me, for example:

List

1

2

3

48

56

88

89

100

 

The numbers above are numbers that I pass as a parameter in the query below calling query 1 (listaPedidos_Aquiles):

let
    ufnCallAPI = (numPedido) =>

        let
            result = Json.Document(Web.Contents("https://api.vhsys.com/", [RelativePath="v2/pedidos/" & Number.ToText(numPedido)  & "/produtos", 
             Headers=[#"access-token"="OCKNYbAMaDgLBZBSQPCOGPWOXGSbdO", #"secret-access-token"="xxxxxxxx"]]))  
        in
            result,

        pageRange = listaPedidos_Aquiles,
        pages = List.Transform(pageRange, each ufnCallAPI(_)),
    pages2 = Table.FromList(pages, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    pages3 = Table.ExpandRecordColumn(pages2, "Column1", {"code", "status", "data"}, {"code", "status", "data"}),
    pages4 = Table.ExpandListColumn(pages3, "data"),
    pages5 = Table.RemoveColumns(pages4,{"code", "status"}),
    #"data Expandido" = Table.ExpandRecordColumn(pages5, "data", {"id_ped_produto", "id_pedido", "id_produto", "desc_produto", "qtde_produto", "desconto_produto", "ipi_produto", "icms_produto", "valor_unit_produto", "valor_custo_produto", "valor_total_produto", "valor_desconto", "peso_produto", "peso_liq_produto", "info_adicional", "xPed_produto", "nItem_produto"}, {"id_ped_produto", "id_pedido", "id_produto", "desc_produto", "qtde_produto", "desconto_produto", "ipi_produto", "icms_produto", "valor_unit_produto", "valor_custo_produto", "valor_total_produto", "valor_desconto", "peso_produto", "peso_liq_produto", "info_adicional", "xPed_produto", "nItem_produto"}),
    #"Personalização Adicionada" = Table.AddColumn(#"data Expandido", "Empresa", each "Aquiles")
in
    #"Personalização Adicionada"

 

With order codes being sent by parameters, the API returns me the list of products for those orders.

When I test with little data, everything works. If I test with all the content (about 30 thousand lines), the system apparently starts to do the operation, I see in the message that everything is being generated correctly, but in the end, I get the error message.

There may actually be more items returning, than pages, but in this case, I am not able to find the error, because in this query2, I do not pass the page paging parameter as I send request by request (number), different from the query 1, that I return a quantity of items per page.


Thank you very much.

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.