calendar.section.update
Обновить календарь
Описание
Метод обновляет календарь.
Параметры
type
string
обязательный
Тип календаря. Возможные значения:
- user — календарь пользователя
- group — календарь группы
ownerId
integer
обязательный
Идентификатор владельца календаря
id
string
обязательный
Идентификатор календаря
name
string
необязательный
Название календаря
description
string
необязательный
Описание календаря
color
string
необязательный
Цвет календаря
text_color
string
необязательный
Цвет текста в календаре
export
object
необязательный
Параметр export
ALLOW
boolean
необязательный
Разрешить экспорт календаря
SET
string
необязательный
Период, за который производить экспорт. Возможные значения:
- all — за весь период
- 3_9 — 3 месяца до и 9 после
- 6_12 — 6 месяцев до и 12 после
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"id":325,"type":"user","ownerId":2,"name":"Changed Section Name","description":"New description for section","color":"#9cbeAA","text_color":"#283099","export":[{"ALLOW":false}]}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/calendar.section.update
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"id":325,"type":"user","ownerId":2,"name":"Changed Section Name","description":"New description for section","color":"#9cbeAA","text_color":"#283099","export":[{"ALLOW":false}],"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/calendar.section.update
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
// Shape of the payload returned in result (match the "response handling" section of the page)
type CalendarSectionUpdateResult = number
try {
const response = await $b24.actions.v2.call.make<CalendarSectionUpdateResult>({
method: 'calendar.section.update',
params: {
id: 325,
type: 'user',
ownerId: 2,
name: 'Changed Section Name',
description: 'New description for section',
color: '#9cbeAA',
text_color: '#283099',
export: [
{
ALLOW: false,
},
],
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
console.info('Updated calendar section ID:', result)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function updateCalendarSection() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'calendar.section.update',
params: {
id: 325,
type: 'user',
ownerId: 2,
name: 'Changed Section Name',
description: 'New description for section',
color: '#9cbeAA',
text_color: '#283099',
export: [
{
ALLOW: false,
},
],
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
console.info('Updated calendar section ID:', result)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', updateCalendarSection)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
try:
bitrix_response = client.calendar.section.update(
type="user",
owner_id=2,
bitrix_id="325",
name="Changed Section Name",
description="New description for section",
color="#9cbeAA",
text_color="#283099",
export={
"ALLOW": False,
},
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Ошибка Bitrix API",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
print(f"Непредвиденная ошибка: {error}")
try {
$response = $b24Service
->core
->call(
'calendar.section.update',
[
'id' => 325,
'type' => 'user',
'ownerId' => 2,
'name' => 'Changed Section Name',
'description' => 'New description for section',
'color' => '#9cbeAA',
'text_color' => '#283099',
'export' => [
[
'ALLOW' => false
]
]
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
// Нужная вам логика обработки данных
processData($result);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error updating calendar section: ' . $e->getMessage();
}
BX24.callMethod(
'calendar.section.update',
{
id: 325,
type: 'user',
ownerId: 2,
name: 'Changed Section Name',
description: 'New description for section',
color: '#9cbeAA',
text_color: '#283099',
export: [
{
ALLOW: false
}
]
}
);
require_once('crest.php');
$result = CRest::call(
'calendar.section.update',
[
'id' => 325,
'type' => 'user',
'ownerId' => 2,
'name' => 'Changed Section Name',
'description' => 'New description for section',
'color' => '#9cbeAA',
'text_color' => '#283099',
'export' => [
[
'ALLOW' => false
]
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "calendar.section.update", b24.Params{
"id": 325,
"type": "user",
"ownerId": 2,
"name": "Changed Section Name",
"description": "New description for section",
"color": "#9cbeAA",
"text_color": "#283099",
"export": []b24.Params{
{
"ALLOW": false,
},
},
})
if err != nil {
return fmt.Errorf("calendar.section.update: %w", err)
}
var value b24.ID
if err := json.Unmarshal(res.Result, &value); err != nil {
return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println("результат:", value)
Ответ
HTTP-статус: 200
{
"result": 190,
"time": {
"start": 1733812564.64201,
"finish": 1733812565.71673,
"duration": 1.0747201442718506,
"processing": 0.05963897705078125,
"date_start": "2024-12-08T06:36:04+00:00",
"date_finish": "2024-12-08T06:36:05+00:00"
}
}
Возвращаемые данные
result
integer
Идентификатор измененного календаря
Обработка ошибок
HTTP-статус: 400
{
"error": "",
"error_description": "Не задан обязательный параметр \"type\" для метода \"calendar.section.update\""
}
| Код | Описание | Значение |
|---|---|---|
| — | Не задан обязательный параметр "type" для метода "calendar.section.update" | Не передан обязательный параметр type |
| — | Не задан обязательный параметр "ownerId" для метода "calendar.section.update" | Не передан обязательный параметр ownerId и параметр type не равен user |
| — | Не задан id секции | Не передан обязательный параметр id |
| — | Недопустимое значение параметра "name" | Передан неверный формат данных в поле name |
| — | Недопустимое значение параметра "description" | Передан неверный формат данных в поле description |
| — | Доступ запрещен | Календарь с указанным id не существует или нет прав для редактирования календаря |
| — | При изменении секции произошла ошибка | Другая ошибка |

