Help with 'Upsert' in Coda API

Hello everyone,

I’m sure this is a rookie mistake, but for the life of me I can’t figure it out. I’m just trying to upsert a row, but it always inserts a new one instead of updating the existing one with the same key column. Can someone please give me a hand?

Here’s a Loom recording with my test: Loom | Free Screen & Video Recording Software | Loom

headers = {'Authorization': 'Bearer '+CODA_API_KEY}
uri = f'https://coda.io/apis/v1/docs/{DOC_ID}/tables/{TABLE_ID}/rows?disableParsing=false'
payload = {
  'rows': [
    {
      'cells': [
        {'column': 'c-LdNOdOjxic', 'value': 123},
        {'column': 'c-Yy758BC3B9', 'value': random.randrange(1,50)},
      ],
      'keyColumns': ['c-LdNOdOjxic']
    },
  ],
}
req = requests.post(uri, headers=headers, json=payload)
req.raise_for_status() # Throw if there was an error.
res = req.json()

thanks!

Pablo

I’m just on my phone now but in the docs it looks like rows and keyColumns should be on the same level. You’ve put keyColumns inside rows

yep, that was it… :man_facepalming:t2: thank you so much!

Pablo

1 Like

Awesome, glad I could help :relaxed:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.