Custom installation page: Error 502 on client.request.invokeTemplate


I’m attempting to get the list of contact fields using the client.request.invokeTemplate method on the installation page.

Here is the code I’m calling:

            domain: THIS.domain,
            api_key: THIS.apikey

And this is the scheme being called:

            "host":"<%= context.domain %>",
            "headers": {
                "Authorization": "Basic <%= encode(context.api_key) %>",
                "Content-Type": "application/json"

I’m getting the error “Error in establishing connection” status 502.

I cannot find an explanation for error 502. I’ve tried adding “:X” to the apikey, including and excluding the protocol line in the template.

I’ve also tried passing a base64 encoded version of the apiKey to the template, but got an error message to say invalid datatype.

Hey @DaveWP,

Does your custom installation page HTML have the JS client?

<script async src="{{{appclient}}}"></script>

Also regarding the context variables,

            domain: THIS.domain,
            api_key: THIS.apikey

Can you confirm if THIS.domain or THIS.apikey has the respective values?

It is does have the expected values, and the code does include the correct script to the Freshdesk library.

Requests work if I use Curl or Excel to make the request.

Yes! The library is using this reference for the JS Client.

Does anyone have a resolution to this issue?

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