D
D
Denis Lysenko2014-08-01 10:22:38
API
Denis Lysenko, 2014-08-01 10:22:38

How to add a task to Bitrix via API?

There is a Bitrix24 box, there is a certain service on Rails. It is necessary that it is possible to somehow add tasks to Bitrix24 from the rail via the API. In which direction to dig? As I understand it, REST is supported only in the cloud, but for a corporate portal you need to dig towards SOAP? Or is it easier to write your own separate script that will insert data directly into the database?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mgordeev, 2016-05-30
@mgordeev

There is no need to contact the database, there is an API:
https://dev.1c-bitrix.ru/api_help/tasks/classes/ct...

R
Rickkk, 2016-06-20
@Rickkk

Now that's exactly what I'm doing - creating tasks through the API. Here is my recent code for creating a task and attaching files to it.

if (CModule::IncludeModule("tasks"))
{
    $arFields = Array(
        "TITLE" => $DATA["APPEND_FIELDS"]["Тема"], 
        "DESCRIPTION" => $DATA['REQTEXT'],
        "RESPONSIBLE_ID" => $DATA['RESPONSIBLE'], //ответственный по задаче
        "GROUP_ID" => 14 //в какую группу добавляем
    );
    

    $obTask = new CTasks;
    $task_ID = $obTask->Add($arFields);
    if($task_ID>0)
    {
    if(!empty($DATA['FILES'])) 
        {
            //подцепим еще файлы к задаче
            foreach($DATA['FILES'] as $file)
            {
                $arFields = Array(
                    "TASK_ID" => $task_ID,
                    "FILE_ID" => $file
                );

                $obTaskFiles = new CTaskFiles;
                $result = $obTaskFiles->Add($arFields);
                if(!$result)
                    $files_problem=true;          
            }
        }


        return array($ID,$files_problem);
    }
    else
    {
        //if($e = $APPLICATION->GetException())
        return $res;
    }

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question