I’m trying to connect an new app on the Platform UI.
In setting up a new trigger, I’m getting the error:
Invalid API Response: - Got a result missing the "id" property ({"pedido":{"desconto":"13,20","observacoes":"","observacaointerna":"","data":"2018-02-28","numero":"1","numeroOrdemCompra":"","vendedor":"","valorfrete":"19.83","totalprodutos":"132.00","totalvenda":"138.63","situacao":"Atendido","dataSaida":"2018-03) What happened (You are seeing this because you are an admin): Executing triggers.pedido_novo.operation.perform with bundle Invalid API Response: - Got a result missing the "id" property ({"pedido":{"desconto":"13,20","observacoes":"","observacaointerna":"","data":"2018-02-28","numero":"1","numeroOrdemCompra":"","vendedor":"","valorfrete":"19.83","totalprodutos":"132.00","totalvenda":"138.63","situacao":"Atendido","dataSaida":"2018-03) Console logs:
Here’s my code:
const options = {
url: 'https://bling.com.br/Api/v2/pedidos/json/',
method: 'GET',
headers: {
'Accept': 'application/json',
'X-APIKEY': bundle.authData.apikey
},
params: {
'apikey': bundle.authData.apikey
}
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
// You can do any parsing you need for results here before returning them
return results.retorno.pedidos;
});
Looking at the documentation how I tried to solve, resulting in the same error:
const options = {
url: 'https://bling.com.br/Api/v2/pedidos/json/',
method: 'GET',
headers: {
'Accept': 'application/json',
'X-APIKEY': bundle.authData.apikey
},
params: {
'apikey': bundle.authData.apikey
}
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
return results.retorno.pedidos.map(function(pedido) {
pedido.id = pedido.numero
delete pedido.numero
return pedido
})
// You can do any parsing you need for results here before returning them
return results.retorno.pedidos;
});
I’m not really a programmer, so I need some help with this.