Created
July 30, 2019 07:53
-
-
Save BedrosovaYulia/224932ea4e864d2ce2687cdf6b3f08ef to your computer and use it in GitHub Desktop.
Updating Bitrix24 list item from AWS Lambda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from botocore.vendored import requests | |
def lambda_handler(event, context): | |
ib_id=event['ib_id'] | |
el_id=event['id'] | |
data={ | |
'IBLOCK_TYPE_ID': 'lists', | |
'IBLOCK_ID': ib_id, | |
'ELEMENT_ID': el_id, | |
} | |
response = requests.get('https://bedrosova.bitrix24.ru/rest/1/****************/lists.element.get',data) | |
list_data=response.json() | |
fields={ | |
"NAME":list_data['result'][0]['NAME'] | |
} | |
for k in list_data['result'][0]: | |
if(k.startswith('PROPERTY')): | |
for k2 in list_data['result'][0][k]: | |
fields[k]=list_data['result'][0][k][k2] | |
fields['PROPERTY_447']='222' | |
data={ | |
'IBLOCK_TYPE_ID': 'lists', | |
'IBLOCK_ID': ib_id, | |
'ELEMENT_ID': el_id, | |
'FIELDS':fields | |
} | |
response = requests.get('https://bedrosova.bitrix24.ru/rest/1/************/lists.element.update',http_build_query(data)) | |
result=response.json() | |
#print(result) | |
return { | |
'statusCode': 200, | |
'body': json.dumps('Hello from Lambda!') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment