Issue while migrating custom apps to fdk version 9 or above

I’m planning to migrate my custom apps to fdk 9.0.5 and facing some issues while doing so.

While trying to substitute iparam values to my request methods, I’m getting error: “error while substituting templates.”. And if I pass hardcoded values, it works. I’m passing fdurl and api_key from custom config page. Please help.

Sample code:

requests.json

{
    "setFDConfig": {
        "schema": {
            "method": "GET",
            "host": "<%= iparam.fdurl %>",
            "path": "/api/v2/ticket_fields",
            "headers": {
                "Authorization": "Basic <%= encode(iparam.api_key) %>"
            }
        },
        "options": {
            "isOAuth": true
        }
    }
}

inside iparams.js

function apiCall() {
    return client.request.invokeTemplate("setFDConfig", {})
}

inside iparams.html

<input class="fdinput" type="text" id="fdurl" placeholder="domain.freshdesk.com" />
</div>
<div>
<input class="fdinput" type="password" id="api_key" placeholder="API Key" />
</div>

Hey @Manish_Jindal,
On the iparams.html, I notice that the domain input’s placeholder is the actual URL value, but the host in request template expects the value to be domain.freshdesk.com without the “https” protocal in the URL.

Passing the value for fdinput as domain.freshdesk.com should work.

The values in requests.json when using the template in custom installation page should be passed with context. And same while invoking the template.

{
    "setFDConfig": {
        "schema": {
            "method": "GET",
            "host": "<%= context.fdurl %>",
            "path": "/api/v2/ticket_fields",
            "headers": {
                "Authorization": "Basic <%= encode(context.api_key) %>"
            }
        },
        "options": {
            "isOAuth": false
        }
    }
}

While invoking,

function apiCall() {
    return client.request.invokeTemplate("setFDConfig", {
         "context": {
              "fdurl": "domain.freshdesk.com",
              "api_key": "APIKEY"
        }
   })
}

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