Добавление своих методов REST API в коробочную Битрикс24

В методе calendar.event.add нет возможности присваивать значения пользовательским полям

Задача была у события календаря изменить пользовательское поле UF_CRM_CAL_EVENT

Добавил новый метод calendar.event.field.update на который должны распространятся разрешения calendar. В файл php_interface\init.php добавил:

// ...

AddEventHandler('rest', 'OnRestServiceBuildDescription', ['\MyRestApi', 'OnRestServiceBuildDescription']);

class MyRestApi
{
	public static function OnRestServiceBuildDescription()
	{
		return [
			'calendar' => [
				'calendar.event.field.update' => [
					'callback' => [__CLASS__, 'calendarEventFieldUpdate'],
					'options' => [],
				],
			],
		];
	}

	public static function calendarEventFieldUpdate($query, $nav, \CRestServer $server)
	{
		if ($query['error'])
		{
			throw new \Bitrix\Rest\RestException(
				'Message',
				'ERROR_CODE',
				\CRestServer::STATUS_PAYMENT_REQUIRED
			);
		}
		
		if (!isset($query['id']))
		{
			return [
				'error' => 'ERROR_METHOD_NOT_FOUND',
				'error_description' => 'Method not found! ' . __LINE__,
			];
		}
		
		if (!isset($query['fields']))
		{
			return [
				'error' => 'ERROR_METHOD_NOT_FOUND',
				'error_description' => 'Method not found! ' . __LINE__,
			];
		}
		
		$id = intval($query['id']);
		
		if ($id <= 0)
		{
			return [
				'error' => 'ERROR_METHOD_NOT_FOUND',
				'error_description' => 'Method not found! ' . __LINE__,
			];
		}
		
		Bitrix\Main\Loader::includeModule('calendar');
		
		$is_data = CCalendarEvent::GetById($id);
		
		if (!$is_data)
		{
			return [
				'error' => 'ERROR_METHOD_NOT_FOUND',
				'error_description' => 'Method not found! ' . __LINE__,
			];
		}
		
		CCalendarEvent::UpdateUserFields($id, $query['fields']);

		return array('result' => 'ok');
	}
}

// ...

 

У класса в функция OnRestServiceBuildDescription возвращает массив со списком разрешений и в каждом разрешении располагается список методов