Hi there, someone can help me?
I’m sending an API Post this way through AJAX
<script>
let firstStepData = {};
let secondStepData = {};
function togglePassagersDropdown() {
var dropdown = document.getElementById("passagersDropdown");
dropdown.style.display = dropdown.style.display === "none" ? "flex" : "none";
}
function applyPassagers() {
var adults = parseInt(document.getElementById("passagersAdults").value);
var children = parseInt(document.getElementById("passagersChildren").value);
var babies = parseInt(document.getElementById("passagersBabies").value);
var totalPassagers = adults + children + babies;
document.getElementById("passagersDropdownBtn").innerText = Passageiros (${totalPassagers});
document.getElementById("passagersDropdown").style.display = "none";
}
function validateFirstStep() {
firstStepData = {
bagage: document.getElementById("bagage").value,
adultos: document.getElementById("passagersAdults").value,
criancas: document.getElementById("passagersChildren").value,
bebes: document.getElementById("passagersBabies").value,
origem: document.getElementById("origem").value,
destino: document.getElementById("destino").value,
ida: document.getElementById("dateInput").value,
volta: document.getElementById("dateInputEnd").value,
flexibilidade: document.getElementById("scales").checked ? "S" : "N"
};
document.getElementById("secondStep").style.display = "block";
document.getElementById("firstStep").style.display = "none";
}
function sendSecondStepData() {
const secondStepData = {
campoNome: document.getElementById("name").value,
campoCelular: document.getElementById("phone").value,
campoOrigem: document.getElementById("origem").value,
campoDestino: document.getElementById("destino").value,
campoDataInicial: document.getElementById("dateInput").value,
campoDataFinal: document.getElementById("dateInputEnd").value,
campoPassageiroAdulto: document.getElementById("passagersAdults").value,
campoPassageiroCrianca: document.getElementById("passagersChildren").value,
campoPassageiroBebe: document.getElementById("passagersBabies").value,
campoFlexibilidade: document.getElementById("scales").checked ? "S" : "N",
campoMalaDespachada: document.getElementById("bagage").value,
campoObservacao: "",
campoCupomDesconto: "",
campoEmail: "",
campoServicos: {
H: document.getElementById("campoHospedagem").checked ? document.getElementById("campoHospedagem").value : "N",
T: document.getElementById("campoTransporte").checked ? document.getElementById("campoTransporte").value : "N",
P: document.getElementById("campoPasseios").checked ? document.getElementById("campoPasseios").value : "N",
S: document.getElementById("campoSeguros").checked ? document.getElementById("campoSeguros").value : "N",
C: document.getElementById("campoCruzeiro").checked ? document.getElementById("campoCruzeiro").value : "N",
}
};
console.log(secondStepData);
jQuery(document).ready(function($) {
var settings = {
"url": "https://agencia.iddas.com.br/orcamento/solicitacao/nova/VWVXRWphb0hsOUZJT2RQTlFZW",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
},
"data": {
"campoNome": secondStepData.campoNome,
"campoCelular": secondStepData.campoCelular,
"campoOrigem": secondStepData.campoOrigem,
"campoDestino": secondStepData.campoDestino,
"campoDataInicial": secondStepData.campoDataInicial,
"campoDataFinal": secondStepData.campoDataFinal,
"campoPassageiroAdulto": secondStepData.campoPassageiroAdulto,
"campoPassageiroCrianca": secondStepData.campoPassageiroCrianca,
"campoPassageiroBebe": secondStepData.campoPassageiroBebe,
"campoFlexibilidade": secondStepData.campoFlexibilidade,
"campoMalaDespachada": secondStepData.campoMalaDespachada,
"campoObservacao": secondStepData.campoObservacao,
"campoCupomDesconto": secondStepData.campoCupomDesconto,
"campoEmail": secondStepData.campoEmail,
"campoServicos": {
H: secondStepData.campoServicos.H,
T: secondStepData.campoServicos.T,
P: secondStepData.campoServicos.P,
S: secondStepData.campoServicos.S,
C: secondStepData.campoServicos.C,
}
}
};
$.ajax(settings)
.done(function(response) {
console.log(response);
console.log("Dados enviados com sucesso!");
document.getElementById("secondStep").style.display = "none";
document.getElementById("confirmation").style.display = "flex";
})
.fail(function(xhr, status, error) {
console.error('Erro ao enviar os dados.', error);
document.getElementById("errorText").style.display = "block";
});
});
}
</script>```
But I'm not able to make this work in the Make HTTP Scenario. I already have a WebHook linked with a Router and a HTTP.