Getting 502 response for addPhoneCall API

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:

Screenshot (30)

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

Seems like some host resolution issue. For testing purposes only just replace the “host”: “<%= iparam.fcrm_api_domain %>” with actual domain value and “Authorization”: “Token token=<%= iparam.fcrm_api_key %>” with actual Auth key and see if it resolves your issue.

Already tried that, didn’t work.

On top of that, we used the client.iparams.get() method to check if the parameters are getting set properly or not, and it is getting set correctly.