S
S
sos1mple2021-02-19 12:06:58
Python
sos1mple, 2021-02-19 12:06:58

Why are the values ​​of the list in Bitrix not updated via the REST API?

Good afternoon.
I'm trying to update the UF value of a list. You must first remove all existing values, and then add new ones.
Python code. The fastbitrix library is used. The code is executed without errors. But the values ​​of the lists in the interface do not change.

res = bx24.call('crm.deal.userfield.get', {'id': '223'})
elems = []
for elem in res['LIST']:
   elems.append({'ID': elem['ID'], 'DEL': 'Y'})
res = bx24.call('crm.deal.userfield.get', {'id': '223', 'LIST': elems})
cur.execute("""SELECT * from docs""")
rows = cur.fetchall()
elems = []
for r in rows:
    doc = r[0]
    elems.append({'VALUE': r[0]})
print(elems)    
res = bx24.call('crm.deal.userfield.update', {'id': '223', 'LIST': elems})

res = bx24.call('crm.deal.userfield.get', {'id': '225'})
elems = []
for elem in res['LIST']:
   elems.append({'ID': elem['ID'], 'DEL': 'Y'})
res = bx24.call('crm.deal.userfield.get', {'id': '225', 'LIST': elems})
cur.execute("""SELECT * from docs""")
rows = cur.fetchall()
elems = []
for r in rows:
    doc = r[0]
    elems.append({'VALUE': r[0]})

res = bx24.call('crm.deal.userfield.update', {'id': '225', 'LIST': elems})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2021-02-24
@sos1mple

Here is the error.
In the `LIST` field, the author tries to send a json structure, while Bitrix is ​​waiting for HTTP parameters.
Thus his original query is:

https://domain.bitrix24.ua/rest/321/apicode/crm.deal.userfield.update.json?ID=223&LIST=[{"id": "49", "DEL": "Y"}]

Should look like this:
https://domain.bitrix24.ua/rest/321/apicode/crm.deal.userfield.update.json?id=223&LIST[0][ID]=49&LIST[0][DEL]=Y

Or, set the header of the sent information in javascript and poison the json:
{
  "id": 223,
  "LIST": [{"id": "49", "DEL": "Y"}]
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question