How to get the URL from a CFHTTP post

Posted on 2004-11-22
Last Modified: 2013-12-24
I'm posting formfields to an application using CFHTTP.  The application returns the variable named "status" indicating if the data is correct or not. When I output the cfhhtp.filecontent I only see the action page but the return variable is displayed only in the URL of the action page.. How do I get the URL from the action page to be displayed?

<cfhttp method="POST"   URL="http://actionpage.asp" resolveurl="yes">
<cfhttpparam type="Formfield" Name="First_Name" value=#fname#>
<cfhttpparam type="Formfield" Name="Last_Name" value=#lname#>
<cfhttpparam type="Formfield" Name="Email" value=#email#>

The action page displays “Thank You for Submiting your Info”

The url of the action page looks like http://actionpage.asp?response=accepted  or  http://actionpage.asp?response=rejected

I’m not able to capture the variable “response”
Question by:gaby22
    LVL 2

    Expert Comment

    Can you modify the ASP page?  I'm not sure it can be done otherwise..I tried a few things with the response header, but no luck.

    If you can modify the ASP page, the easiest thing to do is just have it return the value you want and then have CF display the "Thank You" message.
    LVL 17

    Expert Comment

    Try <cfdump var="#cfhttp#"> and see if there is anything in there that you can use.
    LVL 7

    Accepted Solution

    The URL of HTTP request is (by definition) is the same, at it is provided in the original CFHTTP.  If the URL is different, it means the redirection took place.  If you want to know the URL where request was redirected (and this looks like your case), you have to follow the following scenario:

    1. Issue original CFHTTP with redirects disabled:
       <cfhttp method="POST"   URL="http://actionpage.asp" resolveurl="yes" redirect="no">
       <cfhttpparam type="Formfield" Name="First_Name" value=#fname#>
       <cfhttpparam type="Formfield" Name="Last_Name" value=#lname#>
       <cfhttpparam type="Formfield" Name="Email" value=#email#>

    2. See what is the cfhttp.statusCode.  If this is "200", the request is complete.  If this is "30x" (usually, 302), the redirection URL can be found as:
       <cfset newURL=cfhttp.responseHeader[LOCATION]>
       Analyze this string to see whether "actionpage.asp?response=accepted"  or "actionpage.asp?response=rejected" was returned.

    3. Issue another CFHTTP "GET" request to redirection URL to complete the request.  Note that, if the first URL sets cookies and they are needed on the redirection page, you have to capture them from response header and provide with the second CFHTTP call.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Windows Server with multiple sites and SSL 14 59
    IPA - can it be run on a web server? 3 98
    wordpress limitations 4 73
    Use System DSN 6 62
    Article by: kevp75
    Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
    One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now