I
I
IgorPlays2021-07-02 20:04:50
PHP
IgorPlays, 2021-07-02 20:04:50

Deal update not working?

I have a script that needs to update a deal

<?php
define('C_REST_WEB_HOOK_URL','https://xxxx.bitrix24.kz/rest/1/5rq9wqc7eb6ezrqd/');

require_once('crest.php');

CRest::call('crm.lead.update', [
                 'ID' => 60, //айди взял  с вебхука
                 'FIELDS' => [
                    'TITLE' => 'Lead Name',
      				'NAME' => 'Name',
      				'LAST_NAME' => 'Last name',
                 ]
             ]);
         }

?>


Just an error when starting. The site cannot process this request yet. HTTP ERROR 500

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Grigory Kovalenko, 2021-07-05
@IgorPlays

$prms = array(
    "id" => id_deal,
    "fields" => array(
        "id_field" => 'value',
    ),
);
$prms = json_encode( $prms );
$result = bx24( $prms, 'crm.deal.update' );

function bx24( $params, $type, $portal = '***', $admin_id = '***', $secret_code = '****' ) {
$queryUrl = 'https://' . $portal . '.bitrix24.ru/rest/' . $admin_id . '/' . $secret_code . '/' . $type;
$params = json_decode( $params, true );
$queryData = http_build_query(

    $params
  );

  $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 );

  return json_decode( $result, 1 );
    }
?>

E
Edward, 2021-07-02
@Drayde

To get started, simply output Hello world. The error remained - we fix the server.
According to the script, first try the example according to option No. 2, everything is clearly described in the documentation.
https://dev.1c-bitrix.ru/rest_help/rest_sum/crest.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question