tsturzl tsturzl - 1 year ago 115
HTTP Question

Cannot get node-request to post to salesforce web-to-lead

We've been requested by a client of ours to integrate with their salesforce. However, they refuse to give us an oAuth token. What they did provide was a Web-to-Lead

. Essentially Web-to-Lead is a simple web form that's generated with an
to relate it to your salesforce account. However, I'm having trouble getting anything else to POST to salesforce using curl, postman, or node.js and request module.

I set up a sand box to test this, since they complained that they weren't getting applications. I'm noticing also that theses applications aren't appearing, however if I use the actual form that salesforce generated for me, everything seems to work fine.

Basically me code resembles this:

var request=require("request");

var form={
"street":"xxx Some Road",
"00No00000045Jef":"American Driver Network",
"00No00000045Jek":"Class A",

var options={

//salesforce gives no useful response so do nothing

Request module should be setting my header appropriately.

The salesforce form:

<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <META> element to your page <HEAD>. -->
<!-- If necessary, please modify the charset parameter to specify the -->
<!-- character set of your HTML page. -->
<!-- ---------------------------------------------------------------------- -->

<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">

<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <FORM> element to your page. -->
<!-- ---------------------------------------------------------------------- -->

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

<input type=hidden name="oid" value="00Do0000000KlmA">
<input type=hidden name="retURL" value="http://">

<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: These fields are optional debugging elements. Please uncomment -->
<!-- these lines if you wish to test in debug mode. -->
<!-- <input type="hidden" name="debug" value=1> -->
<!-- <input type="hidden" name="debugEmail" -->
<!-- value="travissturzl@gmail.com"> -->
<!-- ---------------------------------------------------------------------- -->

<label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

<label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

<label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>

<label for="city">City</label><input id="city" maxlength="40" name="city" size="20" type="text" /><br>

<label for="state">State/Province</label><input id="state" maxlength="20" name="state" size="20" type="text" /><br>

<label for="phone">Phone</label><input id="phone" maxlength="40" name="phone" size="20" type="text" /><br>

<label for="street">Address</label><textarea name="street"></textarea><br>

<label for="zip">Zip</label><input id="zip" maxlength="20" name="zip" size="20" type="text" /><br>

Media Type:<input id="00No00000045JeV" maxlength="50" name="00No00000045JeV" size="20" type="text" /><br>

Media Source:<input id="00No00000045Jef" maxlength="50" name="00No00000045Jef" size="20" type="text" /><br>

License Type:<input id="00No00000045Jek" maxlength="50" name="00No00000045Jek" size="20" type="text" /><br>

Months of Experience:<input id="00No00000045Jep" name="00No00000045Jep" size="20" type="text" /><br>

Accidents:<input id="00No00000045Jf4" name="00No00000045Jf4" size="20" type="text" /><br>

Moving Violations:<input id="00No00000045JfE" name="00No00000045JfE" size="20" type="text" /><br>

DUI:<input id="00No00000045JfJ" name="00No00000045JfJ" size="20" type="text" /><br>

<input type="submit" name="submit">


I have no idea what I'm doing wrong. I've never had an issue like this. Am I missing something?

Answer Source

I think you are missing the url in your options:

var options={

You are just making no request without providing the url to post to!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download