Best answer

Got a result missing the "id" property


Userlevel 1

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.

icon

Best answer by ikbelkirasan 3 May 2020, 23:26

@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

This topic has been closed for comments

5 replies

Userlevel 7
Badge +7

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

Userlevel 7
Badge +11

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

 

Userlevel 1

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

And thanks @ikbelkirasan it worked perfectly. 

Userlevel 7
Badge +11

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

Userlevel 7
Badge +7

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