Closed ipeterov closed 2 years ago
I went to https://training.bitrix24.com/rest_help/crm/deals/crm_deal_productrows_set.php and tried using this library like so:
bx24.callMethod( 'crm.deal.productrows.set', id=order_id, rows=[ {'PRODUCT_ID': 12, 'QUANTITY': 1, 'PRICE': 100} ], )
This wasn't working, just removing all product rows from deal. Also response == True, so bitrix wasn't giving much useful info there.
response == True
I realised that in https://github.com/akopkesheshyan/bitrix24-python-rest/blob/master/bitrix24/bitrix24.py#L85 p was like
p
id=540&[rows][PRODUCT_ID]=12...
however bitrix expected
id=540&rows[PRODUCT_ID]=12...
I solved my problem by passing a dict to rows:
bx24.callMethod( 'crm.deal.productrows.set', id=order_id, rows={ 0: {'PRODUCT_ID': 12, 'QUANTITY': 1, 'PRICE': 100} }, )
and got
then my product rows were added to my deal.
Suggestion: refactor https://github.com/akopkesheshyan/bitrix24-python-rest/blob/master/bitrix24/bitrix24.py#L47-L72 to enable this workflow:
It will probably break backward compatibility though.
Well, it looks more like a bug, then feature.
Encoding should work with valid python lists, but in your case it fails.
I'll be pleased if you suggest solution that doesn't break backward compatibility.
I went to https://training.bitrix24.com/rest_help/crm/deals/crm_deal_productrows_set.php and tried using this library like so:
This wasn't working, just removing all product rows from deal. Also
response == True
, so bitrix wasn't giving much useful info there.I realised that in https://github.com/akopkesheshyan/bitrix24-python-rest/blob/master/bitrix24/bitrix24.py#L85
p
was likehowever bitrix expected
I solved my problem by passing a dict to rows:
and got
then my product rows were added to my deal.
Suggestion: refactor https://github.com/akopkesheshyan/bitrix24-python-rest/blob/master/bitrix24/bitrix24.py#L47-L72 to enable this workflow:
It will probably break backward compatibility though.