Search code examples
coldfusioncoldfusion-9

Invalid token @ found while passing email address in cfhttparam


I am trying to pass two email addresses (JSON value) as follows:

 Line#91  <cfhttpparam type="formfield" name="inpEmailObject"
             value="["email1@gmail.com","email2@gmail.com"]" />

However, I am ending up with the following error:

 Invalid token @ found on line 91 at column 75.

The CFML compiler was processing:

    The tag attribute email1, on line 91, column 69.
    A cfhttpparam tag beginning on line 91, column 9.

How can I pass email address in the value field?


Solution

  • If you want to include the double-quote as part of the string you're sending, double it.

    value="[""email1@gmail.com"",""email2@gmail.com""]"
    

    Or, as Antony suggests, change one set to be single-quotes. This should work:

    value='["email1@gmail.com","email2@gmail.com"]'