Skip to main content

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.

Hi @Marcel Khouri ,

 

Take a look at this and see if that helps: https://github.com/zapier/zapier-platform/tree/master/packages/cli#why-are-my-triggers-complaining-if-i-dont-provide-an-explicit-id-field

 

Let me know if that works.

~Bjorn


@Marcel Khouri - Try this code instead:

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;

const pedidos = results.retorno.pedidos.map((obj) => {
const p = obj.pedido;
p.id = p.numero;
return p;
});

return pedidos;
});

 


Thanks @ForYourIT . I tried but I probably missed a detail, because it resulted in the same error.

And thanks @ikbelkirasan it worked perfectly. 


@Marcel Khouri - Great! Glad you got it working :)


@Marcel Khouri that link explained exactly what @ikbelkirasan just gave you. Good job on fixing it!