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
sgeninsgenin 

CURL Error 500 When creating a lead (doesn't always appear)

Hello,

I want to create a lead from my web site using the PHP/SOAP API.

my code is the following :

$client = new SalesforceClient();
$result = $client->login($name,$pass);

if (PEAR::isError($result))
{
$errors = "Error: " . $result->getMessage() . "\n";
echo "

$errors

";
$ret=0;
}
else
{
$client = new SalesforceClient($result->sessionId);
$client->_endpoint = $result->serverUrl;

$query_str = "select Id,description from lead where email='$email' and isConverted=False";

$result = $client->query($query_str);

if (PEAR::isError($result))
{
print "

".$result->getMessage()."
";
print "$query_str

";
$ret=0;
}
else
{
if (count($result->records) == 0)
{
$FIELDS=array(
'type' => 'lead',
'FirstName' => utf8_encode($firstname),
'LastName' => utf8_encode($lastname),
'Title' => utf8_encode($title),
'Company' => utf8_encode(strtoupper($company)),
'Website' => utf8_encode($url),
'Email' => utf8_encode($email),
'Phone' => utf8_encode($phone),
'Street' => utf8_encode($street),
'PostalCode' => utf8_encode($zip),
'City' => utf8_encode($city),
'Country' => utf8_encode($country),
'LeadSource' => utf8_encode($know_us),
'Recevoir_les_Infos_modifi_le__c' => $info_date,
'Recevoir_les_Infos_par_email__c' => utf8_encode($info_str),
'Recevoir_la_Newsletter__c' => utf8_encode($news_str),
'Recevoir_la_Newsletter_modifie_le__c' => $nl_date,
'Origine_du_contact__c' => utf8_encode($source));

$result=$client->create($FIELDS);
}
}
The login is OK.
The select is OK too.

However, I sometimes receive a "curl error 500" on the create, that doesn't occurs every time. I just tried 10 times to add a lead this way, and I received an error. Then, I created a lead using the username/password provided in the login, and after that I retried. My first try was unsuccessful again, then it worked... Once it worked, it seems to be OK during a "certain period of time..." (I had the same behaviour yesterday evening (KO, KO, KO... then OK,OK,OK, but it failed again this morning.


Does someone know where could be the problem?

Thanks
Stéphane
SuperfellSuperfell
SOAP Faults are returned with a 500 status code (as required by the spec) to find out what's wrong, you'll need to parse the soap response and and look at the fault details.