Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
Patching an array in directus via api-call does not work

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?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I figured it out. You need the translations:[] only (remove the preceding name and alt_name).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!