Api request- error while substituting templates

Hi Freshdesk Community,

I am new to the Freshdesk ecosystem and am currently working on integrating a custom application. I’m trying to make a GET request to fetch a contact by ID from a Freshdesk account. However, I have encountered an issue during template substitution, resulting in the following error:

`error while substituting templates. ERR_INVALID_ARG_TYPE`

I’ve gone through the documentation and searched for solutions but haven’t been able to find specific information on how to debug this issue.

Here is a brief overview of what I’m doing:

  • I’m using the client.request.invokeTemplate method to make the request.
  • The request template uses placeholders like iparam.api_key, which I have defined in the iparams.json file.
  • Despite ensuring that the parameters are set correctly, I’m still encountering the substitution error.

I would greatly appreciate it if someone could point me in the right direction or share any tips for debugging this issue.

For reference, I’ve shared a screenshot of my code below (if applicable, attach screenshot here).

requests.json

iparams.json

app.js

Thank you in advance for your help!

Hi @omoh09

Welcome to the Freshworks developer community… :handshake:

Can you hardcode the API key on your header so that we can find the issue

 "getContact": {
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host": "corduni087.freshdesk.com",
      "path": "/api/v2/contacts/501001724176",
      "headers": {
        "Authorization": "Basic <api_key>",  //hardcode the API key here 
        "Content-Type": "application/json"
      }
    }

If the above code works, Please try the same on below

"getContact": {
    "schema": {
      "protocol": "https",
      "method": "GET",
      "host": "corduni087.freshdesk.com",
      "path": "/api/v2/contacts/501001724176",
      "headers": {
        "Authorization": "Basic <%= encode(iparam.api_key + ':X') %>",
        "Content-Type": "application/json"
      }
    }

I am looking forward to hearing from you

Thank you for the contribution
I did hardcoded the api key and i got the following response

okay @omoh09

Can you try the second code that I shared

yes i did, and i get the same response

what could be the issue?
How can i debug this, today would be the last day for my free trial.

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.