Template substitution errored with SyntaxError: Unexpected token ';'

Hello,

We are trying to use the Request API with basic encoding from iparams but get the error “Error while substituting the templates” in the console and “Template substitution errored with SyntaxError: Unexpected token ‘;’” from the debug log. Everything works fine with something like "Basic " + Base64.encode(username + ":" + password).

However we are unable to find any “;” in our parameters.

Are we correct to assume the “;” should be in the iparams.json?

client.request
  .get(
    `hidden`,
    {
      headers: {
        "header1": "Fetch",
        "Content-Type": "application/json",
        Authorization:
          "Basic <%= encode(iparam.YYYHost1User + ':' + iparam.YYYHost1Pwd %>"
      }
    }
  )

Debug log

Substituing Templates

{
  headers: {
            "header1": "Fetch",
            "Content-Type": "application/json",
            Authorization:
              "Basic <%= encode(iparam.yyyHost1User + ':' + iparam.yyyHost1Pwd %>"
          },
  "url": "hidden",
  "method": "get"
}

with

{
  "iparam": {
    "GroupID": "17000148771",
    "YYYSID1": "ABC",
    "YYYHost1": "https://dummy.zzz.com:4300",
    "YYYHost1User": "USERNAME021",
    "YYYHost1Pwd": "Zzz$9",
    "YYYSID2": "YYY",
    "YYYHost2": "https://dummy.zzz.com:4300/",
    "YYYHost2User": "USERNAME021",
    "YYYHost2Pwd": "Zzz$9",
    "YYYSID3": "AAA",
    "YYYHost3": "https://dummy.zzz.com:4300/",
    "YYYHost3User": "USERNAME021",
    "YYYHost3Pwd": "Zzz$9",
    "YYYSID4": "ZZZ",
    "YYYHost4": "https://dummy.zzz.com:4300/",
    "YYYHost4User": "USERNAME021",
    "YYYHost4Pwd": "Zzz$9"
  },
  "oauth_iparams": {}
}

Hi Alex,
Hope you are doing well.

There is a missing ‘)’ in this line
Basic <%= encode(iparam.YYYHost1User + ‘:’ + iparam.YYYHost1Pwd) %>
Can you please try this and let us know if it worked?

Mani Deepak

3 Likes

Misleading error that made me not look where I should have! Thanks, it worked :slight_smile:

2 Likes