O
O
Oleg2018-12-07 13:23:20
Bitrix24
Oleg, 2018-12-07 13:23:20

Webhook not working in Bitrix24?

Good day to all!
Tell me where the error is for the second day, I'm trying to transfer leads from Tilda to the Corporate Portal. Tilda transmits data to Bitrix, and Bitrix in response writes this:

[error_description] => No value entered for the required Subject field.
The value of the required field Project has not been entered.

The code itself:
<?
function writeToLog($data, $title = ''){
    $log = "\n------///BEGIN//////------------------\n";
    $log .= date("Y.m.d G:i:s") . "\n";
    $log .= (strlen($title) > 0 ? $title : 'DEBUG') . "\n";
    $log .= print_r($data, 1);
    $log .= "\n-----/// END ////-------------------\n";
    file_put_contents(getcwd() . '/hook.log', $log, FILE_APPEND);
    return true;
    echo "succes";
}

$defaults = array('TITLE' => '', 'NAME' => '', 'PHONE' => '', 'COMMENTS' => '', 'EMAIL' => '');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
   $defaults = $_REQUEST;
    writeToLog($_REQUEST, 'webform PHP');
  
    $queryUrl  = 'https://какой-то сайт/rest/2363/какие-то циферки и буковки :-) /crm.lead.add.json';
    $queryData = http_build_query(array(
        'fields' => array(
         "TITLE" => $_REQUEST['TITLE'].' '.$_REQUEST['formname'],
                        "NAME" => $_REQUEST['NAME'],
                        "SOURCE_ID" => $_REQUEST['formname'], 
         "COMMENTS" => $_REQUEST['comments'],
         "EMAIL" => $_REQUEST['EMAIL'],
         "ASSIGNED_BY_ID" => 3655,
         "UF_CRM_SEARCH_WORD" => $_GET['utm_term'],
         "UF_CRM_LEAD_LANDING" => $_SERVER['HTTP_HOST'],
         "UF_CRM_CT_UTM_CAMP" => $_GET['utm_campaign'],
         "UF_CRM_CT_UTM_CONT" => $_GET['utm_content'],
         "UF_CRM_CT_UTM_MEDI" => $_GET['utm_medium'],
         "UF_CRM_CT_UTM_SOUR" => $_GET['utm_source'],
         "UF_CRM_CT_UTM_TERM" => $_GET['utm_term'],
         "STATUS_ID" => "NEW",
            "OPENED" => "Y", // ДОСТУПЕН ВСЕМ
            "PHONE" => array(array("VALUE" => $_REQUEST['PHONE'], "VALUE_TYPE" => "WORK" )),
            "EMAIL" => array(array("VALUE" => $_REQUEST['EMAIL_WORK'], "VALUE_TYPE" => "WORK" )),
            //"TITLE" => array("VALUE" => "Заказ с сайта"), 
        ),
        'params' => array("REGISTER_SONET_EVENT" => "Y")
    ));
  
  $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);
 writeToLog($result, 'webform result CURL');

 if (array_key_exists('error', $result)) echo "Ошибка при сохранении лида: ".$result['error_description']."<br/>";
}

?>

Well, hook.log itself:
------///BEGIN//////------------------
2018.12.07 12:34:18
webform PHP
Array
(
    [name] => test
    [email] => [email protected]
    [phone] => 9993331111
    [comments] => test 07-12-2018
    [title] => Другое
    [tranid] => 371618:105293162
    [COOKIES] => _ym_uid=15433207431061138252; _ym_d=1543320743; BX_USER_ID=82ee83d0c3d67e45d4c21098e459e04f; tildauid=1543320770613.872011; _ga=GA1.2.934409917.1543995204; _gid=GA1.2.1113220158.1543995204; _ym_isad=2; _fbp=fb.1.1544167481971.1806725908; tildasid=1544171655529.130527; _ym_visorc_41617929=w; _ym_visorc_51334666=w; previousUrl=velopark.moscow%2F
    [formid] => form31956286
    [formname] => access_VeloPark
)

-----/// END ////-------------------

------///BEGIN//////------------------
2018.12.07 12:34:18
webform result CURL
Array
(
    [error] => ERROR_CORE
    [error_description] => Не введено значение обязательного поля Тематика.<br>Не введено значение обязательного поля Проект.<br>
)

-----/// END ////-------------------

As I understand it, php itself worked, but the system "stumbled" on CURL.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2018-12-12
@molekulo

Judging by the server responses in Bitrix24, you have the required fields "Subject" and "Project", which you do not pass in the CURL request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question