I am trying to perform an API call to patch the name and translations of an element.
translations
is an array with the elements name
and alt_name
identified with a unique id.
The code:
headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json; charset=utf-8"
for row in reader:
data = '{"name": "' + row[1] + '", "alt_name": "' + row[2] + '", ' \
'"translations": [' + \
'{' + \
'"id": "661", "name": "' + row[1] + '", "alt_name": "' + row[2] + '"}, ' + \
'{' + \
'"id": "662", "name": "' + row[3] + '", "alt_name": "' + row[4] + \
'"}]}'
base_url = 'https://URL/path?&access_token=TOKEN'
resp = requests.patch(base_url, headers=headers, data=data)
Everything except inside translations can be modified without problems. Am I missing something obvious?
I figured it out. You need the translations:[] only (remove the preceding name and alt_name).