Request template - error while substituting templates when using iparam in "host"

Hello,

My request template was working, but it’s not any more. I am receiving “error while substituting templates” error

I believe the issue is due to iparam.server being used as “host” value. But this used to work before.

Please advise!

requests.json

{
    "callWebapi2": {
        "schema": {
            "method": "POST",
            "protocol": "https",
            "host": "<%= iparam.server %>",
            "path": "/webapi2?he=JSON1&<%= context.queryparams %>",
            "headers": {
                "Content-Type": "application/json"
            }
        }
    }
}

manifest.json

{
  "platform-version": "2.3",
  "product": {
    "freshdesk": {
      "location": {
        "ticket_sidebar": {
          "url": "index.html",
          "icon": "styles/images/icon.svg"
        }
      },
      "requests": {
        "callWebapi2": {}
      }
    }
  },
  "engines": {
    "node": "18.16.0",
    "fdk": "9.0.1"
  },
  "dependencies": {}
}

Invocation (app.js)

client.request.invokeTemplate("callWebapi2", {
      context: {
        queryparams: "method=utils/login/1"
      },
      body: data
    })

iparams.json

{
    "server": {
        "display_name": "Server Address",
        "description": "Enter Server Address",
        "type": "text",
        "required": true,
        "default_value": "islonline.net",
        "secure": false
    }
}

Hey @isl,

I see the path has query parameters. Can you use the query parameters in the template as explained in request method docs?

{
    "callWebapi2": {
        "schema": {
            "method": "POST",
            "protocol": "https",
            "host": "<%= iparam.server %>",
            "path": "/webapi2?he=JSON1&<%= context.queryparams %>",
            "headers": {
                "Content-Type": "application/json"
            },
            "query": {
                "he": "JSON1",
                "method": "\"<%= context.queryparams %>\""
            }
        }
    }
}

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