function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chris_centrachris_centra 

performing a POST via ASP to Web2Lead...

Hello.  I'm trying to submit a lead via Web2Lead - but programatically.  Below is the essence of the code.  It isn't working.  I don't see any errors, but no lead is created and I don't get the resulting email.  If I create an HTML form and try it, it works perfectly.

I'm doing this programatically because I want to do multiple things with the info.  Send some emails, create a Lead, etc...

Thanks for your time.
Chris

Set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.Open "POST", "http://www.salesforce.com/servlet/servlet.WebToLead", False

QS = "debug=0"
QS = QS & "&encoding=UTF-8"
QS = QS & "&oid=my oid here"
QS = QS & "&debugEmail=my email addr here"
QS = QS & "&first_name=TEST"
QS = QS & "&last_name=TEST"
 

objHttp.Send QS
strResult = objHttp.responseText
Set objHttp = Nothing
 
response.write("[" & QS & "]<br>")
response.write("[" & strResult & "]<br>")
response.end
 
nomisnomis

Hi Chris,

I assume you are talking about classic asp and not dot net as you could use HttpWebRequest instead. Try the following

Dim objHttp

Response.Buffer = True

strUrl = "http://www.salesforce.com/servlet/servlet.WebToLead"

QS = "debug=0"
QS = QS & "&encoding=UTF-8"
QS = QS & "&oid=my oid here"
QS = QS & "&debugEmail=my email addr here"
QS = QS & "&first_name=TEST"
QS = QS & "&last_name=TEST"


Set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.Open "POST",strURL, False
objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHttp.Send QS
strResult = objHttp.responseText
Set objHttp = Nothing

response.write("[" & QS & "]<br>")
response.write("[" & strResult & "]<br>")
response.end

chris_centrachris_centra
That works perfectly - thanks so much for your time!  (And correct, they're using old-school ASP.)

Chris
edeckeredecker
Can this be done using asp.net?
cmarkcmark
yes, it can be done using asp.net.
thanks
chris
nicowensnicowens
I've looked in earnest through searches in the Force.com (Wiki & Blog) and separate Google.com searches.  I cannot find a list of the standard SalesForce.com field names for the querystring parameters.  Can someone point me to a whitepaper or other list of documented field names or the standard naming convention I can assume for fields?
 
- Nick
gogz_sfdcgogz_sfdc
Just generate the form through the UI and you'll have all the field names.

Go to Setup > Customize > Leads > Web 2 Lead > Generate > Select all the fields and click the Generate button it'll give you the html form with all the ids and names set

:)

Hope it helps.