Link to home
Start Free TrialLog in
Avatar of videnda
videnda

asked on

Convert coldfusion http post to ASP code.

I have been supplied with the following coldfusion code, I know that it works for what I need:

<cfhttp url             = "http://gateway.textforce.net/sendsms.cfm"
                      method          = "POST"
                      port            = "80"
                      resolveurl      = "false"
                      throwonerror    = "yes">
<cfhttpparam type="FormField" name="xml" value="#xmlout#">
</cfhttp>

I need the equivalent code in ASP.
I already have this, but it is missing some of the parts above.
(especially how to post the form field)

<%
Set XMLRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
XMLRequest.open "POST", "https://gateway.textforce.net/sendsms.cfm", False
XMLRequest.SetRequestHeader "Host", "gateway.textforce.net"      
XMLRequest.SetRequestHeader "Connection", "Keep-Alive"
XMLRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
%>

Please can someone supply me with the full code?

Regards

Alex
Avatar of hart
hart
Flag of India image

chack this link out
it has XMLRequest.send XMLString maybe that is what u r missing

https://www.experts-exchange.com/questions/20751743/Display-a-particular-node-in-ASP-VBScript.html

Regards
Hart
also this link
http://www-level3.experts-exchange.com/questions/20735798/HTTP-Post-syntax-for-posting-XML-to-a-cfm-file.html

i checked the name in the question, it was urs. ??

Regards
Hart
als check this link out
http://www.codetoad.com/forum/18_22621.asp

Regards
hart
Avatar of videnda
videnda

ASKER

The code you are refering to from a previous question is to post a string.  I am now asking how to set the other parameters, fopr example the throwonerror, and in particular how to post the string as a form field named 'xml' with a value set as the string as in the following code.

<cfhttp url             = "http://gateway.textforce.net/sendsms.cfm"
                     method          = "POST"
                     port            = "80"
                     resolveurl      = "false"
                     throwonerror    = "yes">
<cfhttpparam type="FormField" name="xml" value="#xmlout#">

Thanks for your help so far.
Try this:

<%
Set XMLRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
XMLRequest.open "POST", "https://gateway.textforce.net/sendsms.cfm", False
XMLRequest.SetRequestHeader "Host", "gateway.textforce.net"    
XMLRequest.SetRequestHeader "Connection", "Keep-Alive"
XMLRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
XMLRequest.send("xml=" & Server.URLEncode(xmlout))
%>
The exact same question was asked in the following question and was answered:

https://www.experts-exchange.com/questions/20735798/HTTP-Post-syntax-for-posting-XML-to-a-cfm-file.html

I see no issues with refunding the points since this is a duplicate question.
ASKER CERTIFIED SOLUTION
Avatar of SpazMODic
SpazMODic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial