Cfhttp - Invalid Identifier, the following character cannot be part of an identifier [#]


I tried using with the attributes ‘username’ and ‘password’ and passed the values for ‘password’ and ‘username’ as application variables. The two application variables ‘APPLICATION.myUsername’ and ‘APPLICATION.myPassword’ are initialized with the appropriate values in the ‘onApplicationStart()’ function.

**For example:**
<cfhttp url="myPath/myFile.cfm" method="post" charset="utf-8" username="#APPLICATION.myUsername#" password="#APPLICATION.myPassword#">

Unfortunately I get the following error message:
Invalid Identifier, the following character cannot be part of an identifier [#]

Neither the username nor the password contain the character ‘#’. I therefore suspect that the ‘#’ characters delimiting the application variables are causing the error. I can’t imagine that this behavior in the tag is intentional?!

Out of curiosity, does this work?

<cfhttp url="myPath/myFile.cfm" method="post" charset="utf-8" username=APPLICATION.myUsername password=APPLICATION.myPassword>

Yes, this surprisingly works.

Is this an intended behavior or is this a bug?

1 Like

Sending the authorization in the header as ‘httpparam’ would also work as an alternative:

<cfhttpparam type="header" name="Authorization" value="Basic #ToBase64('#APPLICATION.myUsername#:#APPLICATION.myPassword#')#">
1 Like

I suggested skipping quotes based on recalling this:

It’s not quite the same use-case and certainly feels like a bug based on the info provided. Maybe someone else can confirm. For reference @Knut what’s your version / environment?

I can’t reproduce the bug with that code snippet?

which version of Lucee? Stacktrace?

Oh man, shame on my head - I have to apologize to you guys.

When the error occurred, in my test scenario I had a small error in the password stored in the application variable and it did not match the .htpasswd.

Then, when I ran the test without surrounding #…# (as @Phillyun suggested), I also fixed the password error and it worked.

After that I didn’t do another test with surrounding #…#. Otherwise, I would have noticed that everything works flawlessly. That’s why @Zackster couldn’t reproduce an error.

At least I learned something new from @Phillyun’s hint “Handling unquoted arguments as variables :: Lucee Documentation”. Many Thanks.

Sorry again and thank you for your kind help.
I’m going down to the basement now and I’m ashamed…


Glad you got it sorted and thanks for the follow-up, too.
It’s always good to read how something was solved.

The amount of times I google for something - find the “exact” match to what I need and the thread end with;
“Thanks - I got it working”

But then… provides no details on how it was resolved … ARRRGH!