(Another) Error while substituting templates - Custom app to bridge two freshdesk instances


Currently, I’m developing an custom app that will perform a simple task:
Inside freshdesk instance A, there will be an input box to write an ID. The app must simply take this ID and retrieve the ticket informations from freshdesk instance B (both are freshdesk instances).

This is the current setup:


client.request.invokeTemplate("ticketsById", {
    context: {
      "ticket_id": text
    .then((res) => console.log(res.response))
    .catch((err) => console.log(err));


  "url": {
    "display_name": "URL Destino",
    "description": "Please enter your URL Destino",
    "type": "text",
    "required": true
  "apikey": {
    "display_name": "API Key",
    "description": "Please enter your API Key",
    "type": "api_key",
    "required": true,
    "type_attributes": {
      "product": "name of the product"
    "secure": true


    "ticketsById": {
        "schema": {
            "method": "GET",
            "host": "<%= iparam.url %>",
            "path": "/api/v2/tickets/<%= context.ticket_id %>",
            "headers": {
                "Authorization": "Basic <%= encode(iparam.apikey) %>",
                "Content-Type": "application/json"
        "options": {}

Whenever I try to run the app, I get the error “error while substituting templates.”.
The files are named correctly and the iparams are set using the /custom_configs

The fdk.log result is simply:

2024-03-18 16:38:48.578 +0000 [debug] (e[34mdata.jse[0m) e[31mRead {"fw_101_101_freshdesk":{"fw_101_101_custom_iparams":{"__meta":{"secure":["apikey"]},"url":"appteste.freshdesk.com","apikey":"********(redacted)**********"}}}e[0m

2024-03-18 16:38:48.579 +0000 [debug] (e[34mrequest.jse[0m) e[31merror while validating schema for ticketsByIde[0m

2024-03-18 16:38:50.174 +0000 [debug] (e[34mcoverage.jse[0m) e[31mWriting coverage.e[0m

But in the response, I get:

Any help would be appreciated, it seems like it might be a simple fix, however I cannot pinpoint the issue, as I am a pretty new Freshworks Developer.


Hi @Jose_Cruz ,

It appears that you forgot to include the “protocol”: “https” parameter in your request method. Please add it as shown below and attempt again.

“fdGetMethod”: {
“schema”: {
“method”: “GET”,
“protocol”: “https”
“host”: “<%= iparam.fdurl %>”,
“path”: “/api/v2/<%= context.path %>”,
“headers”: {
“Authorization”: “Basic <%= encode(iparam.api_key) %>”,
“Content-Type”: “application/json”


Hi @Jose_Cruz,

Does this request method work if the host, path, and Authorization headers are hard-coded with static values?
If it works, could you replace it one by one and check which variable is causing the issue?

Please verify if the variable limitations are considered and used accordingly.

If it still fails and you can’t find it, please add where this API request is made from and if the iparams are already submitted.

1 Like

Hello @Gopi,

Thank you for your response, unfortunately adding the protocol did not help.

1 Like

Hello @Raviraj ,

I replaced all the parameters with their hardcoded values one by one, and it still didn’t work.

As far as I can tell, the iparams are correctly submitted since the fdk log shows that the request is using them.

As for the variables, I am using iparams in the host and in the headers, and contextual data in the path, so it seems to be according to the limitations.

@Jose_Cruz Does it work if all the variables are hard-coded with static values at a time?

If it works, there’s some issue with one of the variables due to the value not present or not accessible.

There’s no restriction on using context variables in the path property. So, it will work if it’s properly sent.

If the iparams are submitted and properly used, they will be available as well. So, could you double-check them as well?


No. I’ve switched the variables to hardcoded values, and it doesn’t work still

I’ve double checked everything else, manifest and iparams and everything is ok

@Jose_Cruz What is the error code and message says now?
I hope it’s not an “error while substituting templates” as there are no variables used.

1 Like

@Raviraj you were right, I had made a mistake while replacing the static values.

Now it works with static values! But for some reason, this:

Is returning all of the tickets from the other instance, instead of ticket number 2.

Edit: I now cannot even get anything to return, when I use static values I just get an error stating that I must be logged in:

@Jose_Cruz This error means that the Base64 encoded value and the complete value for the Authorization property are not solving to the real API key.

For the API key alone, could you use the iparam with the following syntax and try to see if it works?

"Authorization": "Basic <%= encode(iparam.apikey) %>"

It was my idea that once all the hard-coded value works, you can try to replace one by one and find which one is failing and find the root cause to resolve it.

There are variable limitations as mentioned in the docs here.

Perfect. Adding the “encode” fixed the issue.

I have done as you said and replaced the variables one by one and the one that is causing the issue is the <%= context.ticket_id %>

1 Like

@Jose_Cruz Awesome. Thanks for your confirmation.

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