1

Good afternoon everyone!

I have a query in Power BI, where I have a column with "PedidoId".

I have a function that creates a URL using the "PedidoId" column.

When this function is called, the data loads normally locally. However, when I try to update the credentials in the Power BI webservice, I get the following error below. Please note that this API endpoint requires me to pass the "PedidoId" number. Can someone help me? I've tried a lot of things.

let
get_pedido_atendido = (pedidoId as number) =>
let
    baseUrl = "https://api.sienge.com.br/domainexemplo/public/api/v1/purchase-invoices/deliveries-attended?purchaseOrderId=",
    response = Web.Contents(
        baseUrl,
        [
            RelativePath = "",
            Query = [purchaseOrderId = Number.ToText(pedidoId)]
        ]
    ),
    json = Json.Document(response)
in
    json

in get_pedido_atendido

Segue erro:

Falha ao atualizar as credenciais da fonte de dados: Web.Contents failed to get contents from 'https://api.sienge.com.br/domainexemplo/public/api/v1/purchase-invoices/deliveries-attended?purchaseOrderId=' (400): Bad RequestOcultar detalhes

Código de status: 400 Hora: Wed May 28 2025 14:27:40 GMT-0300 (Horário Padrão de Brasília)

1 Answer 1

0

First replace the BaseUrl by the following url:

"https://api.sienge.com.br/domainexemplo/public/api/v1/purchase-invoices"

After that replace the response by:

response = Web.Contents(
        baseUrl,
        [
            RelativePath = "deliveries-attended",
            Query = [purchaseOrderId = Number.ToText(pedidoId)]
        ]
    )

The issue was happening because you already included the url parameter purchaseOrderId in the BaseUrl so you have duplicated this parameter resulting in a wrong endpoint and hence getting a 400 bad request error code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.