无法将节点请求发送到salesforce web-to-lead

时间:2014-08-08 20:26:37

标签: javascript node.js http request salesforce

我们的客户要求我们与他们的销售人员整合。但是,他们拒绝向我们提供oAuth令牌。他们所提供的是网络导向oid。从本质上讲,Web-to-Lead是一个简单的Web表单,由oid生成,用于将其与您的salesforce帐户相关联。但是,我无法使用curl,postman或node.js和请求模块向salesforce发送任何其他内容。

我设置了一个沙盒来测试这个,因为他们抱怨说他们没有获得应用程序。我也注意到这些应用程序没有出现,但是如果我使用salesforce为我生成的实际表单,一切似乎都能正常工作。

基本上我的代码类似于:

var request=require("request");

var form={
    "oid":"xxxx",
    "first_name":"TEST",
    "last_name":"TEST",
    "email":"xxxx@gmail.com",
    "street":"xxx Some Road",
    "city":"somewhere",
    "state":"Wisconsin",
    "zip":"54944",
    "00No00000045JeV":"Internet",
    "00No00000045Jef":"American Driver Network",
    "00No00000045Jek":"Class A",
    "00No00000045Jep":"50",
    "00No00000045Jf4":"0",
    "00No00000045JfE":"0",
    "00No00000045JfJ":"0",
    "retURL":"http://"
};

var options={
    url:"",
    form:form
};

request.post(options,function(err,resp,body){
    //salesforce gives no useful response so do nothing
});

请求模块应该正确设置我的标题。

salesforce表单:

<!--  ----------------------------------------------------------------------  -->
<!--  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">

</form>

我不知道我做错了什么。我从未遇到过像这样的问题。我错过了什么吗?

1 个答案:

答案 0 :(得分:2)

我认为您错过了选项中的网址:

var options={
    url:"https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8",
    form:form
};

如果没有提供要发布的网址,您只是没有要求!