0

I use python library request to add a new task on bitrix24 by api. But when i use my code,i can't call to deadline function.

fields = {"fields":{"TITLE":"name",
                    "DESCRIPTION":"content",
                    "DEADLINE":'09/12/2019 07:00:00 pm',
                    "ALLOW_CHANGE_DEADLINE":1,
                    "RESPONSIBLE_ID":1}
}
url = 'https://xxxxxxxxx.bitrix24.com/rest/1/xxxxxxx/tasks.task.add'

r= requests.post(url,json=fields)

Anyone know how to fix this?

2 Answers2

0

If you return any task from B24 you will get date like '2016-12-30T00:00:00+03:00'. The date must be putted in similar format: '2019-12-09' or '2019-09-12'. I didn't check with time. You can use module datetime and format your date variable by datetime.date.isoformat()

0

You can use incoming webhook and fast_bitrix24 library to work with the Bitrix24 REST API. To create a webhook, go to Applications > Webhooks. Here is the code that works for me.

from fast_bitrix24 import *
webhook = 'https://xxxxxxxxx.bitrix24.com/rest/1/xxxxxxx/'
b = Bitrix(webhook)
b.call('tasks.task.getFields',{}) # Returns all fields in a task
b.call('tasks.task.add', {'fields':{'TITLE':'name', 'RESPONSIBLE_ID':1, 'DEADLINE':'2021-03-09 15:00'}})

Links to resources:

https://github.com/leshchenko1979/fast_bitrix24

https://dev.1c-bitrix.ru/rest_help/tasks/task/tasks/tasks_task_add.php