Bitrix24 webhook/REST API

1.5k views Asked by At

I'd like to create TASK in bitrix24 with webhook URL. Almost everything is fine (task name, description, responsible, deadline etc...) the only problem is with field with several users (Observers and Participants). I don't know how to add these parameters to the URL :( The documentation is incomplete.

2

There are 2 answers

0
Mohamed Ali O.Ameur On

The solution is easy, I didn't see your code but per the API doc, you need to encode the JSON array of fields as parameters into the GET request: this will help you: How should I put json in GET request?

A better approach would be using POST to submit data instead of GET, this way you don't need to do the above, you can send the array as it.

Example of an array of fields:

Array
        (
            [TITLE] => Process lead: +19196299012 - Outgoing call (set from business process)
            [STAGE_ID] => 0
            [DESCRIPTION] => Process lead: +19196299012 - Outgoing call
            [DEADLINE] => 
            [START_DATE_PLAN] => 
            [END_DATE_PLAN] => 
            [PRIORITY] => 0
            [ACCOMPLICES] => Array
                (
                )

            [AUDITORS] => Array
                (
                )

            [TAGS] => Array
                (
                )

            [ALLOW_CHANGE_DEADLINE] => Y
            [ALLOW_CHANGE_DEADLINE_COUNT] => 
            [ALLOW_CHANGE_DEADLINE_COUNT_VALUE] => 
            [ALLOW_CHANGE_DEADLINE_MAXTIME] => 
            [ALLOW_CHANGE_DEADLINE_MAXTIME_VALUE] => 
            [TASK_CONTROL] => Y
            [PARENT_ID] => 
            [DEPENDS_ON] => Array
                (
                )

            [GROUP_ID] => 0
            [RESPONSIBLE_ID] => 1
            [TIME_ESTIMATE] => 0
            [ID] => 130
            [CREATED_BY] => 1
            [DESCRIPTION_IN_BBCODE] => Y
            [DECLINE_REASON] => 
            [REAL_STATUS] => 2
            [STATUS] => 2
            [RESPONSIBLE_NAME] => Mohamed Ali
            [RESPONSIBLE_LAST_NAME] => Ouled Ameur
            [RESPONSIBLE_SECOND_NAME] => 
            [DATE_START] => 
            [DURATION_FACT] => 
            [DURATION_PLAN] => 
            [DURATION_TYPE] => days
            [CREATED_BY_NAME] => Mohamed Ali
            [CREATED_BY_LAST_NAME] => Ouled Ameur
            [CREATED_BY_SECOND_NAME] => 
            [CREATED_DATE] => 2021-06-26T08:12:39+03:00
            [CHANGED_BY] => 1
            [CHANGED_DATE] => 2021-06-26T08:12:39+03:00
            [STATUS_CHANGED_BY] => 1
            [STATUS_CHANGED_DATE] => 2021-06-26T08:12:39+03:00
            [CLOSED_BY] => 
            [CLOSED_DATE] => 
            [ACTIVITY_DATE] => 2021-06-26T08:12:39+03:00
            [GUID] => {bcd84631-6c08-4124-8db2-7cfe90628dc1}
            [MARK] => 
            [VIEWED_DATE] => 2021-06-28T09:09:17+03:00
            [TIME_SPENT_IN_LOGS] => 
            [FAVORITE] => N
            [ALLOW_TIME_TRACKING] => N
            [MATCH_WORK_TIME] => N
            [ADD_IN_REPORT] => Y
            [FORUM_ID] => 
            [FORUM_TOPIC_ID] => 
            [COMMENTS_COUNT] => 
            [SITE_ID] => s1
            [SUBORDINATE] => Y
            [FORKED_BY_TEMPLATE_ID] => 
            [MULTITASK] => N
            [UF_CRM_TASK] => Array
                (
                    [0] => L_38
                    [1] => L_38
                )

            [UF_MAIL_MESSAGE] => 
            [UF_TASK_WEBDAV_FILES] => 
        )
1
Roland Kom On

to set more then one, you can use this. In the array every usernumber

$accomplice = ['1','2'];

$createTask = CRest::call('tasks.task.add',

...
'ACCOMPLICES' => $accomplice,
...