View comments | RSS feed

cfhttpparam

Description

Required for a cfhttp POST operation. Specifies parameters to build the operation.

Category

Forms tags, Internet Protocol tags

Syntax

<cfhttpparam 
  name = "name"
  type = "type"
  value = "transaction type"
  file = "filename">

See also

cfftp, cfhttp, cfldap, cfmail, cfmailparam, cfpop

Attributes

Attribute Req/Opt Default Description
name
Required

Variable name for data that is passed
type
Required

Transaction type:
  • URL
  • FormField
  • Cookie
  • CGI
  • File
value
Optional if type = "File"

Value of URL, FormField, Cookie, File, or CGI variables that are passed.
file
Required if type = "File"

File name

Usage

This tag's parameter values are URL-encoded, so the values of special characters (such as the ampersand) are preserved when they are passed to the server. For more information, see the function URLEncodedFormat.

Example

<p>This view-only example shows the use of cfhttpparam to show the values 
of passed variables on another HTML reference, accessed by cfhttp. 
The other file could output the value of form.formtest, url.url_test,
cgi.cgi_test, and cookie.cookie_test to prove that this page is working:

<h3>Sample Other File Listing</h3>
<cfoutput>#HTMLCodeFormat("

<html>
<head>
<title>Sample Page</title>
</head>

<body>
<h3>Output the passed variables</h3>
<cfoutput>
  Form variable: ##form.form_test##
  <br>URL variable: ##URL.url_test##
  <br>Cookie variable: ##Cookie.cookie_test##
  <br>CGI variable: ##CGI.cgi_test##
</cfoutput>
</body>
</html>

")#</cfoutput>

<!--- <p>
<cfhttp 
    method = "post" url = "http://localhost/someotherfile.cfm">
  <cfhttpparam 
    name = "form_test" type = "FormField" value = "This is a form variable">
  <cfhttpparam 
    name = "url_test" type = "URL" value = "This is a URL variable">
  <cfhttpparam
    name = "cgi_test" type = "CGI" value = "This is a CGI variable">
  <cfhttpparam 
    name = "cookie_test" type = "Cookie" value = "This is a cookie">
</cfhttp>

<cfoutput>
    #cfhttp.fileContent#
</cfoutput> --->

ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


carehart@systemanage said on Nov 25, 2002 at 11:52 AM :
This page fails to mention that when passing a value for the name attribute when trying to use type="cgi", the name is NOT the same as the CGI variable name as CF exposes it. For instance, if you want to pass in a "referer", you wouldn't say CFHTTPPARAM Type="cgi" Name="http_referer" Value="somevalue".

Instead, you need to drop the "http_" and just say Name="referer". And for headers/cgi variables that have multiple parts to their name, such as HTTP_Accept_Encoding, note too that the value to use isn't just "Accept_Encoding".

Instead, you have to use the formal name for the header, as speced at the w3c site among others, http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html. In this case, you'd use Name="accept-encoding", which is typical for their multi-word values.

It would be nice for the CFMX docs to clarify this, as I'm sure many pull their hair out trying to get this to work, relying on their knowledg of these "CGI" variables solely from how they appear in the CF debugging info or a dump of the CGI scope.
tjordahl101 said on Dec 17, 2002 at 10:49 AM :
Please note that there is an XML type in addition to those listed. Only a single usage of this parameter type is allowed. This will POST with a content type of "text/xml". Sample usage:
<CFXML variable="myXML">
<test>
<string>this is a test</string>
</test>
</CFXML>

<Cfhttp method="POST" url="http://localhost/post.cfm">
<cfhttpparam type="XML" name="body" value="#ToString(myXML)#">
</CFHTTP>
csteinola said on Sep 23, 2003 at 6:11 PM :
If I want to pass a header like

POST /Annotation HTTP/1.1
or even
HTTP/1.1 201 Created

using HTTPPARAM type="HEADER"... what would go in the "name" attribute?
halL said on Sep 24, 2003 at 7:26 AM :
The header attribute was added with ColdFusion MX 6.1.
This page documents ColdFusion MX 6.0.
For 6.1 documentation, see http://livedocs.macromedia.com/coldfusion/6.1/.
Jwahl said on Feb 1, 2004 at 6:48 AM :
Suppose I have to send a certificate in the header of an XML request, I have tried this:

<Cfhttp method="POST" url="http://localhost/post.cfm">
<cfhttpparam type="HEADER" name="myCertificate" value="#myCert#">
<cfhttpparam type="XML" name="body" value="#ToString(myXML)#">
</CFHTTP>

Is there any other whay I can do this?

Jwahl
No screen name said on Mar 31, 2004 at 9:17 AM :
the target of my http post requires a parameter be NULL by which I believe is meant the equivalent of the url string

target?parm00=value1&parm01=


i don't see any way of coding this in CFHTTPPARAM

coding the CFHTTPPARAM value="" does not seem to generate the expected value.

any ideas?
No screen name said on Mar 31, 2004 at 10:14 AM :
Re: NULL CFHTTPPARAM
It's actually worse than I thought.

The target server webmaster says I should set the parameter to the equivalent of the perl statement

my $variable = undef;

anyone have any ideas how to do this ?
:

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/Tags-pt155.htm