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

Hi

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:

client.request.invokeTemplate("getContactFields",{
          context:{
            domain: THIS.domain,
            api_key: THIS.apikey
          }
  });

And this is the scheme being called:

        "schema":{
            "protocol":"https",
            "method":"GET",
            "host":"<%= context.domain %>",
            "path":"/api/v2/contact_fields",
            "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,

context:{
            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.