Carlos Melo
Member
Hi,
Please someone tell why Webhook by Pabbly step is not displaying data that that come into it from a form.
I am getting the following results in my tests:
1. The URL is working because the Webhook by Pabbly app shows that something tried to reach it but was unable to receive any data, as you can see on the image below:
2. This is the error log I got from the browser console after submitting the form:
Failed to load resource: the server responded with a status of 406 ()
3. Every workflow history shows the data that reached the workflow, from all attempts made. You can check one of them in this one:
Task History ID - IjU3NjUwNTZkMDYzMDA0MzQ1MjY1NTUzNzUxMzY1MTYyNTQzMjBmMzci_pc
That is the code block to send the data via the webhook URL to the workflow:
<script>
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('input_54').addEventListener('click', function(event) {
event.preventDefault(); // Impede o envio automático do formulário
enviarParaPabbly(); // Chama a função para enviar os dados para o Pabbly
});
});
function enviarParaPabbly() {
var origem = document.getElementById('origem').value;
var destino = document.getElementById('destino').value;
var distancia = document.getElementById('distancia').innerText;
var valorAPagar = Math.max(parseFloat(distancia) * 3, 8);
var nome = document.getElementById('input_49').value;
var whatsapp = document.getElementById('input_50').value;
var codigoViagem = document.getElementById('input_10').value;
const data = {
origem: origem,
destino: destino,
distancia: distancia,
valor_a_pagar: valorAPagar.toFixed(2),
nome: nome,
whatsapp: whatsapp,
codigo_viagem: codigoViagem,
};
// Insira o console.log aqui para verificar os dados antes do envio
console.log('Dados antes do envio ao Pabbly:', data);
fetch('https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjYwNTZkMDYzZjA0MzU1MjY1NTUzNTUxMzYi_pc', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data),
})
.then(response => {
console.log('Resposta do Pabbly:', response);
if (response.ok) {
console.log('Dados enviados para o Pabbly com sucesso.');
document.getElementById('240736343582054').submit();
} else {
console.error('Erro ao enviar os dados para o Pabbly:', response.status, response.statusText);
alert('Ocorreu um problema ao enviar os dados. Tente novamente.');
}
})
.catch(error => {
console.error('Erro na solicitação:', error);
alert('Erro ao enviar os dados. Verifique sua conexão e tente novamente.');
});
}
</script>
Workflow: https://connect.pabbly.com/workflow...aUTAOGgIGVQMFdgEbBAZXVAV_VxoCeQZfWGtcAlB4A2I#
Please someone tell why Webhook by Pabbly step is not displaying data that that come into it from a form.
I am getting the following results in my tests:
1. The URL is working because the Webhook by Pabbly app shows that something tried to reach it but was unable to receive any data, as you can see on the image below:
2. This is the error log I got from the browser console after submitting the form:
Failed to load resource: the server responded with a status of 406 ()
3. Every workflow history shows the data that reached the workflow, from all attempts made. You can check one of them in this one:
Task History ID - IjU3NjUwNTZkMDYzMDA0MzQ1MjY1NTUzNzUxMzY1MTYyNTQzMjBmMzci_pc
That is the code block to send the data via the webhook URL to the workflow:
<script>
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('input_54').addEventListener('click', function(event) {
event.preventDefault(); // Impede o envio automático do formulário
enviarParaPabbly(); // Chama a função para enviar os dados para o Pabbly
});
});
function enviarParaPabbly() {
var origem = document.getElementById('origem').value;
var destino = document.getElementById('destino').value;
var distancia = document.getElementById('distancia').innerText;
var valorAPagar = Math.max(parseFloat(distancia) * 3, 8);
var nome = document.getElementById('input_49').value;
var whatsapp = document.getElementById('input_50').value;
var codigoViagem = document.getElementById('input_10').value;
const data = {
origem: origem,
destino: destino,
distancia: distancia,
valor_a_pagar: valorAPagar.toFixed(2),
nome: nome,
whatsapp: whatsapp,
codigo_viagem: codigoViagem,
};
// Insira o console.log aqui para verificar os dados antes do envio
console.log('Dados antes do envio ao Pabbly:', data);
fetch('https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjYwNTZkMDYzZjA0MzU1MjY1NTUzNTUxMzYi_pc', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data),
})
.then(response => {
console.log('Resposta do Pabbly:', response);
if (response.ok) {
console.log('Dados enviados para o Pabbly com sucesso.');
document.getElementById('240736343582054').submit();
} else {
console.error('Erro ao enviar os dados para o Pabbly:', response.status, response.statusText);
alert('Ocorreu um problema ao enviar os dados. Tente novamente.');
}
})
.catch(error => {
console.error('Erro na solicitação:', error);
alert('Erro ao enviar os dados. Verifique sua conexão e tente novamente.');
});
}
</script>
Workflow: https://connect.pabbly.com/workflow...aUTAOGgIGVQMFdgEbBAZXVAV_VxoCeQZfWGtcAlB4A2I#