• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Cfhttpparam Tag form data error

New Here ,
May 23, 2022 May 23, 2022

Copy link to clipboard

Copied

Hi All, Facing a weired issue in cfhttpparam, when I hard code a string value it goes without quotes: as seen in fireshark capture below:

harpreets72075604_0-1653356972865.png

But when this string is done dunamicly it gets wraped in "". adding Quotes makes it fail in third party REST API. see below line which adds quotes

<cfhttpparam type="formField" name="annotation" value="#some variables#">

Views

114

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 24, 2022 May 24, 2022

Copy link to clipboard

Copied

Yes, that's strange. Does the variable contain by chance an extra pair of quotes? When I did the following test, I couldn't reproduce the problem.

 

I placed test1.cfm and test2.cfm in the webroot, launched test1.cfm in the browser, and then examined the HTML file in the logs folder.

 

test1.cfm

 

<!--- Dynamically --->
<cfset annotation="97bb0158-d392-e9d3-7b7a-a78ec8347140">
<cfhttp url="http://127.0.0.1:8500/test2.cfm" method="post">
	<cfhttpparam type="formfield" name="annotation" value="#annotation#" encoded="false" >
	<cfhttpparam type="formfield" name="annotationVariableValueType" value="dynamically" >
</cfhttp>

<!--- Hard-coded --->
<cfhttp url="http://127.0.0.1:8500/test2.cfm" method="post">
	<cfhttpparam type="formfield" name="annotation" value="97bb0158-d392-e9d3-7b7a-a78ec8347140" encoded="false" >
	<cfhttpparam type="formfield" name="annotationVariableValueType" value="hardcoded" >
</cfhttp>
done

 

 

test2.cfm

 

<cfscript>	
	writedump(var=GetHttpRequestData(), format="html", output="#server.coldfusion.rootdir#\logs\HttpRequestData.html");
</cfscript>

 

 

Result:

BKBK_0-1653394332274.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 25, 2022 May 25, 2022

Copy link to clipboard

Copied

I'm not sure what "#some variables#" is supposed to represent. This syntax will let you include ONE expression. Just one. Maybe you can show the specific code you're trying to execute in there? Thanks in advance!

 

Dave Watts, Eidolon LLC

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 25, 2022 May 25, 2022

Copy link to clipboard

Copied

LATEST

 

<cfhttpparam type="formField" name="annotation" value="#some variables#">


By @harpreets72075604

 

It just occurred to me that "#some variables#" may include CFML code. That is, it may not just consist of a variable name. That would explain the presence of an extra pair of quotes.

 

If so, then I have 2 suggestions. You may use either:

<cfset annotationValue = code_to_evaluate_the_annotation>
<cfhttpparam type="formField" name="annotation" value="#annotationValue#">

 

<cfset annotationValue = code_to_evaluate_the_annotation>
<cfhttpparam type="formField" name="annotation" value=#annotationValue#>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation