We are building a CTI app for CRM and trying to implement addPhoneCall API: Develop Cloud-Telephony Integration (CTI) for Freshworks CRM
We are using invokeTemplate to call this API.
The function we are using to call the function is as follows:
function addPhoneCall(clickedNumberId, call, note) {
client.data.get("loggedInUser").then(
function () {
const formData = {
phone_call: {
call_direction: call.type.toLowerCase().includes("incoming") || call.type.toLowerCase().includes("inbound"),
targetable_type: 'Contact',
targetable: {
id: clickedNumberId
},
note: {
description: note
},
number: call.phone_number,
}
};
const body = {
"phone_call": JSON.stringify(formData.phone_call)
};
let response = client.request.invokeTemplate('addPhoneCall', {
body
});
log(response);
},
);
}
Our request template is as follows:
"addPhoneCall": {
"schema": {
"protocol": "https",
"method": "POST",
"host": "<%= iparam.fcrm_api_domain %>",
"path": "/crm/sales/api/cti_phone_calls",
"headers": {
"Authorization": "Token token=<%= iparam.fcrm_api_key %>",
"Content-Type": "application/json"
}
},
"options": {
"isOAuth": false
}
}
The request payload from the Developer Tool is as follows:
We keep getting this 502 error as follows:
We were able to run this API successfully using Postman and the Curl command. The main issue is when calling the API from within the app we get this Error message.
Thanks in advance for any help