For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
CFML Reference / 

http

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

Description

Used in CFScript to generate an HTTP request and handle the response from the server.

Syntax

Mode

Syntax

Creating the service

new http() or createObject("component","http")

Initializing the attributes

Any one of the following:

  • httpService=new http(_attribute-value_pair_)
  • httpService.setAttributes(_attribute-value_pair_)
  • httpService.set_AttributeName_(attribute_value)
  • httpService.send(attribute-value_pair)

Executing the service action

httpService.send(_attribute-value_pair_)

Properties

url

charset

clientcert

clientcertpassword

columns

delimiter

file

firstrowasheaders

getasbinary

method

multipart

multiparttype

name

password

path

port

proxyserver

proxyport

proxyuser

proxypassword

redirect

resolveurl

result

textqualifier

throwonerror

timeout

useragent

username

All attributes supported by the tag cfhttp can be used as attribute-value pairs. For example,

<cfhttp name="onerow">

can be used as

httpService.setName("onerow");

For details of the attributes, see the Attributes section for the tag cfhttp.

See also

cfhttp__, Function summary

History

ColdFusion 9: Added this function.

Methods

  • addParam

    Description

    Used to add cfhttpparam tags. For example, to specify http POST operations in CFScript. Specifies parameters to build an HTTP request.

    Syntax

    httpService.addParam(attribute-value pair)

    Returns

    Nothing

    Arguments

    All attributes supported by cfhttpparam tag can be used as attribute-value pairs.

     

  • send

    Description

    Used to generate an HTTP request and handle the response from the server.

    Returns

    A component on which the following methods can be invoked:

     

  • GetResult(): To access the query object returned by the server if a name attribute is specified.
  • GetPrefix(): To access the cfhttp scope. This is equivalent to the result attribute of the cfhttptag.

    Syntax

    httpService.send(attribute_value pair)

    Arguments

    All attributes supported by the cfhttpparam tag.

     

  • setAttributes

    Description

    Sets attributes for the http function.

    Returns

    Nothing

    Syntax

    httpService.setAttributes (attribute-value pair)

    Arguments

    All arguments supported by the cfhttp tag.

     

  • getAttributes

    Description

    Gets attributes that were set for the http function.

    Returns

    Returns a struct with all or some of the service tag attribute values.

    Syntax

    httpService.get_Attributes_(attribute_list)

    Arguments

    A comma-separated list of attributes. If no list is specified, all defined attributes are returned.

     

  • clearAttributes

    Description

    Removes all attributes added for the http function.

    Returns

    Nothing

    Syntax

    httpService.clearAttributes(attribute_list)

    Arguments

    A comma-separated list of attributes.

     

  • clearParams

    Description

    Removes cfhttpparam tags that were added using the addParam method.

    Returns

    Nothing

    Syntax

    httpService.clearParams()

    Arguments

    None

     

  • clear

    Description

    Removes all attributes and cfhttpparam tags that were added using the addParam method.

    Returns

    Nothing

    Syntax

    httpService.clear()

    Arguments

    None

     

Usage

This function corresponds to the cfhttp tag. For usage details, see the Usage section for cfhttp in the CFML Reference.

Example

<!--- Get Video --->
<!---
<cfset videoName = "<video path>\hello.wmv">
<cfset videoFileName = "hello.wmv">
--->
<!--- Set User Account Data --->
<!---
<cfset clientKey = "enter client key from google"/>
<cfset devKey = "ebtdev key from google>"/>
--->
<cfscript>
/* youtube uplaod url */
youTubeUploadURL = "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
/* video to upload */
videoName = ExpandPath('./hello.wmv');
videoFileName = "hello.wmv";
/* set user account data */
clientKey = "enter client key from google";
devKey = "ewnter dev key from google";
/* create new http service */
httpService = new http();
/* set attributes using implicit setters */
httpService.setMethod("post");
httpService.setCharset("utf-8");
httpService.setUrl("https://www.google.com/accounts/ClientLogin");
/* add httpparams using addParam() */
httpService.addParam(type="formfield",name="accountType",value="HOSTED_OR_
GOOGLE");
httpService.addParam(type="formfield",name="Email",value="enter gmail id");
httpService.addParam(type="formfield",name="Passwd",value="enter password");
httpService.addParam(type="formfield",name="service",value="youtube");
httpService.addParam(type="formfield",name="source",value="youtubecode");
/* make the http call to the URL using send() */
result = httpService.send().getPrefix();
/* process the filecontent returned */
content = listtoarray(result.filecontent,chr(10));
for(i=1;i lte arraylen(content);i++)
{
item = content[i];
authdata[listFirst(item, "=")] = listRest(item, "=");
}
</cfscript>
<!--- Create ATOM XML and save to a file to be sent with video --->
<cfsavecontent variable="meta">
<cfoutput>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:yt="http://gdata.youtube.com/schemas/2007">
<media:group>
<media:title type="plain">WithOutQuotes</media:title>
<media:description type="plain">Test Description</media:description>
<media:category
scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People
</media:category>
<media:keywords>yourvideo</media:keywords>
</media:group>
</entry>
</cfoutput>
</cfsavecontent>
<cfscript>
tmpfile = expandPath("./meta.xml");
FileWrite(tmpfile,trim(meta));
/* use the httpService created above */
httpService.setUrl("http://uploads.gdata.youtube.com/feeds/api/users/default/
uploads");
httpService.setTimeOut(450);
httpService.setMultipartType("related");
/* clear params first */
httpService.clearParams();
/* add httpparams using addParam() */
httpService.addParam(type="header",name="Authorization", value="GoogleLogin auth=#authdata.auth#");
httpService.addParam(type="header",name="X-GData-Client", value="#variables.clientkey#");
httpService.addParam(type="header",name="X-GData-Key", value="key=#variables.devkey#");
httpService.addParam(type="header",name="Slug",value="#videoFileName#");
httpService.addParam(type="file",name="API_XML_Request",file="#tmpfile#",
mimetype=
"application/atom+xml");
httpService.addParam(type="file",name="file",file="#videoName#",mimetype
="video/*");
/* make the http call to the URL using send() */
result = httpService.send().getPrefix();
if(result.statuscode contains "201")
{
WriteOutput("Your video has been successfully uploaded to YouTube");
}
else
{
WriteOutput("There was a problem uploading the video. Status code returned was " & result.statuscode);
}
</cfscript>

 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices