Freshdesk CLI "Error while substituting the templates"

I was trying to make a request to my freshdesk domain, but I’m getting the following error “Error while replacing templates” when trying to update a ticket field. I don’t do how to solve this error, I searched the internet, but I found nothing.

1 Like

Hi @Lucas_de_Lagos_Pando,
Welcome to the community!
Can you please share with me the request API which you are trying?
and I hope you whitelisted your request call in the manifest and are you using the correct Iparams key?
Reference Link: App Manifest and Request Method

Thanks

Hi @Santhosh, a request I’m trying to make is as follows:

function UpdateSLA(data) {
  try {
    var obj = JSON.parse(data.response);
    const response = {
      name: obj.sla
    };
    const options = {
      headers: {
        "Authorization": "Basic <%= encode(authorize) %>",
        "Content-Type": "application/json"
      },
      body: JSON.stringify(response)
    };
    $request.put("https://domain.freshdesk.com/api/v2/tickets/2585", options)
      .then(
        function (data) {
          console.log("deu certo parabens");
          console.log(data);
        },
        function (error) {
          console.log(error);
          console.log("1");
        }
      )
  }
  catch (error) {
    console.error(error)
    console.error("deu errado parça")
  };
}

@Lucas_de_Lagos_Pando,
I think

"Authorization": "Basic <%= encode(authorize) %>",

authorize is wrong it seems, you need to change it to an API key like iparam.keyname

and make sure the URL is whitelisted in manifest

Hope it helps :slight_smile:

Thanks

@Santhosh, the api key I put directly into the code without using this Iparam.Keyname, how and where would I use it ?

Thanks

@Lucas_de_Lagos_Pando,
Using API key directly in the code is not advisable, hence API key will be different for each Admin,
so I would request you to take a look at Installation Parameters, App Manifest and Request Method and this will help you on what is Iparams and how to use IParams in the app and request API.

Thanks

1 Like

@Santhosh, Realizing the previous procedures in the documentation, however I continue to receive the same error. Is there anything else I can do?

Thanks

Hi @Santhosh !

Many of our users are experiencing an error and the console shows this same error. I’ve debugged and found out that the <%= access_token => is not being set correctly. I’ve confirmed this since I’ve manually overwritten the access_token for the token it should be replaced with and it works all right.

This is an urgent matter as all of our users are experiencing this issue and is a vital part of our app. Do you have any recommendations on how to fix this or is it an issue you are aware of and are currently working to solve?

Thanks!

@Lucas_de_Lagos_Pando , @juventinoromero
I hope you guys know about the latest security announcement,
Security updates to the platform - 19 May 2021 - Announcements - Freshworks Developer Community
we are not allowing the template parser in the body,
kindly get back to us if you are facing any issues with template parsing in the header itself.

Thanks

4 Likes

Yes! I’ve just found out. I will work on that immediately.

Thanks!

2 Likes

@Santhosh, @juventinoromero
Solve the problem as follows:

headers: {
        "Authorization": Basic QmpES1ladkpYbmtDSlo6,
        "Content-Type": "application/json"
      },

After many attempts I decided to get my API KEY and encode it in base64, done that I passed my key in base64 in authorization and it worked. Thank you for all the support and attention in the case.

2 Likes