Answer the question
In order to leave comments, you need to log in
Why is the name not added to the lead in Bitrix24?
Using the rest api, I'm trying to add a lead to Bitrix 24 ..
The title and phone number are added to the lead, but the name does not want .. What could be the problem?
$nameStart = $_POST["nameStart"];
$phoneStart = $_POST["phoneStart"];
$pos = "Заявка с сайта";
// формируем URL в переменной $queryUrl
$queryUrl = 'https://домен/rest/6/идентификатор/crm.lead.add.json';
// формируем параметры для создания лида в переменной $queryData
$queryData = http_build_query(array(
"fields" => array(
'TITLE' => $pos, // НАЗВАНИЕ
'NAME' => $nameStart , // ИМЯ
'OPENED' => 'Y', // Доступно для всех
'SOURCE_ID' => "WEB", //Источник вебсайт
//"ASSIGNED_BY_ID" => 1, Ответственный
"PHONE" => array(array("VALUE" => $phoneStart, "VALUE_TYPE" => "WORK" )),
),
'params' => array("REGISTER_SONET_EVENT" => "Y")
));
// обращаемся к Битрикс24 при помощи функции curl_exec
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $queryUrl,
CURLOPT_POSTFIELDS => $queryData,
));
$result = curl_exec($curl);
curl_close($curl);
$result = json_decode($result, 1);
if (array_key_exists('error', $result)) echo "Ошибка при сохранении лида: ".$result['error_description'].
"<br/>";
Answer the question
In order to leave comments, you need to log in
Maybe you have a custom field with a name?
There are several ways to find this out.
For example:
1. Go to any lead
2. Open the console (press F12)
3. Select the "Name" field and see what id
If the default name should really be NAME:
If the name field was added manually, then the id will be of the following form :
Check if your $nameStart variable is empty. Also, all required parameters must be specified. Try adding SECOND_NAME. It is also mandatory.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question