tasks.template.checklist.addAttachmentByContent
Добавить вложение в пункт чек-листа по содержимому
Описание
Метод tasks.template.checklist.addAttachmentByContent добавляет вложение в пункт чек-листа по содержимому файла.
Параметры
templateId
integer
обязательный
Идентификатор шаблона задачи.
Идентификатор шаблона задачи можно получить при создании нового шаблона
checkListItemId
integer
обязательный
Идентификатор пункта чек-листа.
Идентификатор пункта чек-листа шаблона можно получить при создании нового пункта или методом получения списка пунктов
attachmentParameters
object
обязательный
Параметры создаваемого вложения (подробное описание)
Параметр attachmentParameters
NAME
string
необязательный
Имя создаваемого файла
CONTENT
string
необязательный
Содержимое файла в формате base64
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"templateId": 139,
"checkListItemId": 37,
"attachmentParameters": {
"NAME": "dashboard-note.txt",
"CONTENT": "RGFzaGJvYXJkIG5vdGU="
}
}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/tasks.template.checklist.addAttachmentByContent
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"templateId": 139,
"checkListItemId": 37,
"attachmentParameters": {
"NAME": "dashboard-note.txt",
"CONTENT": "RGFzaGJvYXJkIG5vdGU="
},
"auth": "**put_access_token_here**"
}' \
https://**put_your_bitrix24_address**/rest/tasks.template.checklist.addAttachmentByContent
// 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 CheckListItemResult = {
checkListItem: {
id: number
copiedId: number | null
userId: number
createdBy: number | null
parentId: number
title: string
sortIndex: number
displaySortIndex: string
isComplete: boolean
isImportant: boolean
completedCount: number
members: Array<{
id: string
type: string
name: string
personalPhoto: string
personalGender: string
image: string
isCollaber: boolean
}>
attachments: unknown[]
nodeId: number | null
templateId: number
}
}
try {
const response = await $b24.actions.v2.call.make<CheckListItemResult>({
method: 'tasks.template.checklist.addAttachmentByContent',
params: {
templateId: 139,
checkListItemId: 37,
attachmentParameters: {
NAME: 'dashboard-note.txt',
CONTENT: 'RGFzaGJvYXJkIG5vdGU=',
},
},
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(result.checkListItem.id, result.checkListItem.title)
}
} 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 addAttachmentByContent() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'tasks.template.checklist.addAttachmentByContent',
params: {
templateId: 139,
checkListItemId: 37,
attachmentParameters: {
NAME: 'dashboard-note.txt',
CONTENT: 'RGFzaGJvYXJkIG5vdGU=',
},
},
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(result.checkListItem.id, result.checkListItem.title)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', addAttachmentByContent)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
attachment_parameters = {
"NAME": "dashboard-note.txt",
"CONTENT": "RGFzaGJvYXJkIG5vdGU=",
}
try:
bitrix_response = client.tasks.template.checklist.add_attachment_by_content(
template_id=139,
check_list_item_id=37,
attachment_parameters=attachment_parameters,
).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(
'tasks.template.checklist.addAttachmentByContent',
[
'templateId' => 139,
'checkListItemId' => 37,
'attachmentParameters' => [
'NAME' => 'dashboard-note.txt',
'CONTENT' => 'RGFzaGJvYXJkIG5vdGU='
]
]
);
$result = $response
->getResponseData()
->getResult();
print_r($result);
} catch (Throwable $e) {
echo $e->getMessage();
}
BX24.callMethod(
'tasks.template.checklist.addAttachmentByContent',
{
templateId: 139,
checkListItemId: 37,
attachmentParameters: {
NAME: 'dashboard-note.txt',
CONTENT: 'RGFzaGJvYXJkIG5vdGU='
}
},
function(result)
{
if (result.error())
{
console.error(result.error());
}
else
{
console.log(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'tasks.template.checklist.addAttachmentByContent',
[
'templateId' => 139,
'checkListItemId' => 37,
'attachmentParameters' => [
'NAME' => 'dashboard-note.txt',
'CONTENT' => 'RGFzaGJvYXJkIG5vdGU='
]
]
);
print_r($result);
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "tasks.template.checklist.addAttachmentByContent", b24.Params{
"templateId": 139,
"checkListItemId": 37,
"attachmentParameters": b24.Params{
"NAME": "dashboard-note.txt",
"CONTENT": "RGFzaGJvYXJkIG5vdGU=",
},
})
if err != nil {
return fmt.Errorf("tasks.template.checklist.addAttachmentByContent: %w", err)
}
// Метод заворачивает ответ в объект с ключом "checkListItem".
raw, ok := b24.Unwrap(res.Result, "checkListItem")
if !ok {
return fmt.Errorf("в ответе нет ключа checkListItem")
}
var item struct {
ID b24.ID `json:"id"`
UserID b24.ID `json:"userId"`
ParentID b24.ID `json:"parentId"`
Title string `json:"title"`
SortIndex int `json:"sortIndex"`
DisplaySortIndex string `json:"displaySortIndex"`
}
if err := json.Unmarshal(raw, &item); err != nil {
return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println(item.ID, item.UserID)
Ответ
HTTP-статус: 200
{
"result": {
"checkListItem": {
"id": 37,
"copiedId": null,
"userId": 503,
"createdBy": null,
"parentId": 23,
"title": "4. Подготовить дашборд и отправить ссылку",
"sortIndex": 2,
"displaySortIndex": "",
"isComplete": false,
"isImportant": true,
"completedCount": 0,
"members": [
{
"id": "547",
"type": "A",
"name": "Анна Петрова",
"personalPhoto": "57129",
"personalGender": "",
"image": "https://mysite.ru/b17053/resize_cache/57129/c0120a8d7c10d63c83e32398d1ec4d9e/main/137/137bfa78b877be117e75f1ac8652834a/anna.png",
"isCollaber": false
}
],
"attachments": [],
"nodeId": null,
"templateId": 139
}
},
"time": {
"start": 1773303072,
"finish": 1773303072.349161,
"duration": 0.34916090965270996,
"processing": 0,
"date_start": "2026-03-12T11:11:12+03:00",
"date_finish": "2026-03-12T11:11:12+03:00",
"operating_reset_at": 1773303672,
"operating": 0.2779998779296875
}
}
Возвращаемые данные
result
object
Объект с данными ответа (подробное описание).
Новый файл не отображается в ответе метода tasks.template.checklist.addAttachmentByContent в attachments. Чтобы получить данные о новом файле выполните метод tasks.template.checklist.get
time
time
Информация о времени выполнения запроса
Обработка ошибок
HTTP-статус: 400
{
"error": "100",
"error_description": "Could not find value for parameter {templateId}"
}
| Код | Описание | Значение |
|---|---|---|
400 |
100 |
Could not find value for parameter {templateId} |
400 |
100 |
Bitrix\Tasks\CheckList\Internals\CheckList All parameters in the constructor must have real class type |
400 |
100 |
Could not find value for parameter {attachmentParameters} |
400 |
0 |
Произошла ошибка при добавлении вложения |
400 |
0 |
Изменение элемента: действие недоступно |

