[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

How to get the URL from a CFHTTP post

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#>
</cfhttp>
  <cfoutput>#cfhttp.FileContent#</cfoutput>

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”
0
gaby22
Asked:
gaby22
1 Solution
 
dlewis9Commented:
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.
0
 
Tacobell777Commented:
Try <cfdump var="#cfhttp#"> and see if there is anything in there that you can use.
0
 
INSDivision6Commented:
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#>
   </cfhttp>

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.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now