Skip to main content
Best answer

Got a result missing the "id" property


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.

Best answer by ikbelkirasanBest answer by ikbelkirasan

@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;
});

 

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

ForYourIT
Forum|alt.badge.img+7
  • Tinkerer
  • 259 replies
  • May 3, 2020

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


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • Answer
  • May 3, 2020

@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. 


ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • May 3, 2020

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


ForYourIT
Forum|alt.badge.img+7
  • Tinkerer
  • 259 replies
  • May 4, 2020

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