Upload File to Task task.item.addfile
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.
Scope:
taskWho can execute the method: any user
DEPRECATED
The development of this method has been halted. Please use tasks.task.files.attach.
This method uploads a file to a task. Currently, file upload is implemented via post, with the file content passed in the CONTENT parameter.
Method Parameters
|
Name |
Description |
|
TASK_ID |
Task identifier |
|
NAME |
File name |
|
CONTENT |
File content in |
Code Examples
How to Use Examples in Documentation
cURL (Webhook)
cURL (OAuth)
JS
PHP
BX24.js
PHP CRest
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"TASK_ID":"140","FILE":{"NAME":"desc.txt","CONTENT":"BASE64_ENCODED_CONTENT_OF_DESC.TXT"}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/task.item.addfile
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"TASK_ID":"140","FILE":{"NAME":"desc.txt","CONTENT":"BASE64_ENCODED_CONTENT_OF_DESC.TXT"},"auth":"z3eamwwkpgl7u18kx14q1s4c0ffckqsn"}' \
https://**put_your_bitrix24_address**/rest/task.item.addfile
try
{
const response = await $b24.callMethod(
"task.item.addfile",
{
TASK_ID: "140",
FILE: {
NAME: "desc.txt",
CONTENT: "BASE64_ENCODED_CONTENT_OF_DESC.TXT"
}
}
);
const result = response.getData().result;
console.log(result);
}
catch( error )
{
console.error(error);
}
try {
$response = $b24Service
->core
->call(
'task.item.addfile',
[
'TASK_ID' => '140',
'FILE' => [
'NAME' => 'desc.txt',
'CONTENT' => 'BASE64_ENCODED_CONTENT_OF_DESC.TXT',
],
]
);
$result = $response
->getResponseData()
->getResult();
if ($result->error()) {
error_log($result->error());
echo 'Error: ' . $result->error();
} else {
echo 'Success: ' . print_r($result->data(), true);
}
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error adding file to task: ' . $e->getMessage();
}
BX24.callMethod(
"task.item.addfile",
{
TASK_ID: "140",
FILE: {
NAME: "desc.txt",
CONTENT: "BASE64_ENCODED_CONTENT_OF_DESC.TXT"
}
},
function(result) {
if(result.error())
console.error(result.error());
else
console.log(result.data());
}
);
require_once('crest.php');
$result = CRest::call(
'task.item.addfile',
[
'TASK_ID' => "140",
'FILE' => [
'NAME' => 'desc.txt',
'CONTENT' => base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] .'/desc.txt'))
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Copied