I am getting an Error while substituting the templates error when attempting to make 3 separate API calls to Freshservice. I am working on updating a large client’s code from 2.2 to 2.3 and am following the migration guide provided by Freshworks, but following those steps has resulted in this error. My code calls the GET requester with iclient.request.invokeTemplate("fdGetMethod",{context:{"path":"requester_fields"}}
Within requests.js I have defined the fdGetMethod as follows:
fdurl is defined within iparams.html and is linked to the input.
I make this call for requester_fields, department_fields, and ticket_form_fields. All the calls return with “Error while substituting the templates”. From the console I can tell they are all returning a rejected promise.
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?
The iparams are being filled on iparams.html on installation so they are present before the get call (the form for this input is below, the “Verify Freshservice” button is the one making the call to the API with the given input)
I am considering the variable limitations and using the context variable to provide the path in the api call and the get method as shown below. This is how it is shown in the migration guide.
This was exactly the issue. The domain and api key were being submitted in iparams.html, so they were not accessible yet during the installation process. I passed domain/api-key into the request as variables in context and it worked.
Thank you very much to everyone who helped me get through this issue!