I’m developing a custom app and I’m having the following problem…
I’m getting custom fields from a ticket as follows:
onTicketCreateHandler: function (args) {
var requestTicketCustomFields = args.data.ticket.custom_fields;
var client = args.data.ticket.custom_fields.cf_cliente_1586027;
var produtooperadora;
var categoria;
var subcategoria;
for (var property in requestTicketCustomFields) {
if (requestTicketCustomFields[property] != null) {
if (property.includes("cf_produtooperadora")) {
produtooperadora = requestTicketCustomFields[property]
}
if (property.includes("cf_categoria")) {
categoria = requestTicketCustomFields[property]
}
if (property.includes("cf_subcategoria")) {
subcategoria = requestTicketCustomFields[property]
}
}
}
The code above is working normally.
After executing this part I create an object to receive the information I want, like this:
const apiRequest = {
Category_: categoria,
SubCategory_: subcategoria,
ProductOperator_: produtooperadora,
Client_: client
}
Once that’s done, I send this object to a third party API where I’ll check the information of this object and return some information. I’m sending this object as follows:
var response = {
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(apiRequest)
}
var sla;
$request.post("https://url.net/api/RelationshipRecord", response)
.then(
function (data) {
sla = data;
},
function (error) {
console.log("O erro abaixo ocorreu ao efetuar a requisição que retorna o sla.");
console.error(error);
}
);
So far, everything is working. The next step would be to post the variable that received the API data. However, this is where the error arises, when I try to post the variable on the webhook.site site it returns a “No content”, I did some tests on my API using postman and it returns the information normally. I don’t know why this is happening… the way I’m trying to send this variable is as follows:
var responseApiCsharp = {
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(sla)
}
$request.post("https://webhook.site", responseApiCsharp)
.then(
function (data) {
console.log(data);
},
function (error) {
console.error(error);
}
);