You need to sign in to do that
Don't have an account?
craskul
Problem creating lead using API
Hello Everybody,
I'm pretty new to the API and I am having a problem with creating a lead. It gives me the error of Required Fields Missing. Below the code, I'll paste in the responses I get. I've also pasted in the arrays and sobject to view although I took the print_r()'s out of the code below.
FYI: I don't want to use the web-to-lead because my next step is to add more functionality when capturing a lead. I thought I'd first start with getting a lead into the system first.
Here is my code (which is pretty much from one of the samples just changed to creating a lead vs. account:
Code ( I took out the login portion):
Responses:
This is the fields array
This is the sObject
As you can see, the sObject Array has the fields in it. So I don't know how to solve this problem. Any help would be greatly appreciated.
Thanks,
Chris
I'm pretty new to the API and I am having a problem with creating a lead. It gives me the error of Required Fields Missing. Below the code, I'll paste in the responses I get. I've also pasted in the arrays and sobject to view although I took the print_r()'s out of the code below.
FYI: I don't want to use the web-to-lead because my next step is to add more functionality when capturing a lead. I thought I'd first start with getting a lead into the system first.
Here is my code (which is pretty much from one of the samples just changed to creating a lead vs. account:
Code ( I took out the login portion):
$fields = array (
'LastName' => $_POST['last_name'],
'Company' => $_POST['company'],
'Salutation' => $_POST['salutation'],
'FirstName' => $_POST['first_name'],
'Title' => $_POST['title'],
'Phone' => $_POST['phone'],
'Email' => $_POST['email'],
'LeadSource' => $_POST['lead_source']
);
$sObject = new SObject();
$sObject->type = 'Lead';
$sObject->fields = $fields;
echo "**** Creating the following:\r\n";
$createResponse = $mySforceConnection->create($sObject);
session_write_close();
} catch (Exception $e) {
echo $mySforceConnection->getLastRequest();
echo $e->faultstring;
}
Responses:
This is the fields array
Array
(
[LastName] => Last123123
[Company] => testing
[Salutation] =>
[FirstName] => First123
[Title] => test
[Phone] => 949-555-1212
[Email] => test@tetst.com
[LeadSource] => Website
)
This is the sObject
SObject Object**** Creating the following:
(
[type] => Lead
[fields] => Array
(
[LastName] => Last123123
[Company] => testing
[Salutation] =>
[FirstName] => First123
[Title] => test
[Phone] => 949-555-1212
[Email] => test@tetst.com
[LeadSource] => Website
)
)
stdClass Object
(
[errors] => stdClass Object
(
[fields] => Array
(
[0] => LastName
[1] => Company
)
[message] => Required fields are missing: [LastName, Company]
[statusCode] => REQUIRED_FIELD_MISSING
)
[id] =>
[success] =>
)
As you can see, the sObject Array has the fields in it. So I don't know how to solve this problem. Any help would be greatly appreciated.
Thanks,
Chris
Chris
This is my code:
$Sforce = new SforceEnterpriseClient ();
$mySoapClient = User::$Sforce->createConnection("sfa/enterprise.wsdl.xml");
$mylogin = User::$Sforce->login(SFA_LOGIN, SFA_PASSWORD);
$newLead = new SObject ();
$newLead->fields = array (
'LastName' => $lastname,
'Company' => $company);
$newLead->type = 'Lead';
$response = $Sforce->create (array($newLead), "Lead");
And it does not work. The reply is the same as in the post above.
Any ideas?
should be:
I just changed the WDSL.
I don't know why... Maybe some bug in the API.
Anyway, thanks.