coldfusioncfhttpcfhttpparam

cfhttp and cfhttpparam in ColdFusion


I have some XMl data, I want to use the XML data to be posted to a scheduler job so using cfhttp and cfhttpparam. But for reason after running this code I was not able to schedule a job in one of my site. Tried all the options with formfields, url and xml with no success. I was saving all my data into a xml variable using cfsavecontent and using that variable to pass into cfhttparam value. Not sure what Am I doing wrong here. Here is the below code

<cfsavecontent variable="getAllValues">
    <start_job job="/cf/ecs/get_ecspseg1_data">
        <params>
        <param name="1_script" value="#script#" />
        <param name="2_login" value="#login#"/>
        <param name="3_customer" value="#customer#"/>
        <param name="4_account" value="#account#"/>
        <param name="5_begdate" value="#begdate#"/>
        <param name="6_enddate" value="#enddate#"/>
        </params>
    </start_job>
</cfsavecontent>

<cfhttp url="http://ecs" port="4444" username="test" authType = "BASIC" password="testing*1" method="post">
    <cfhttpparam type="xml" name="testing" value="#ToString(getAllValues)#"/>
</cfhttp>

here is the updated code:

<cfsavecontent variable="getAllValues">
    <start_job job="/cf/smartecs/get_pseg1_data">
        <params>
        <param name="1_script" value="#script#" />
        <param name="2_login" value="#login#"/>
        <param name="3_customer" value="#customer#"/>
        <param name="4_account" value="#account#"/>
        <param name="5_begdate" value="#begdate#"/>
        <param name="6_enddate" value="#enddate#"/>
        </params>
    </start_job>
</cfsavecontent>

<cfhttp url="http://10.xxx.xxx.xxx" port="4444" username="myusername" authType = "BASIC" password="mypassword" method="post" >
    <cfhttpparam type="header" name="Content-Type" value="application/octet-stream">
    <cfhttpparam type="body" name="testing"  value="#getAllValues#"/>
</cfhttp>

Solution

  • When using a different Port number we need to even keep a / at the end of the URL. When I kept that / at the end of the URL it worked like a charm. ColdFusion will not accept : in the URL.