Tables app: API cannot update field data

Please help with Nextcloud’s Table App and looking for example.

Here is the schema for a row of data in Nextcloud’s Table App retrieved using api endpoint…
“/index.php/apps/tables/api/1/rows/41”

{
  "id": 41,
  "tableId": 5,
  "createdBy": "XXX",
  "createdAt": "2026-01-20 03:03:26",
  "lastEditBy": "XXX",
  "lastEditAt": "2026-01-20 03:03:26",
  "data": [
    {
      "columnId": 29,
      "value": "Testing2"
    },
    {
      "columnId": 30,
      "value": "Date Time"
    },
    {
      "columnId": 31,
      "value": 7541
    }
  ]
}

I would like to update the value in field (column) 31 using the API. Looking at the Swagger docs. It suggests the code below should work.

data = {"columnId":31, "value": 3333}
tbl_data = {}

tbl_data['data'] = data
url = f"{nextcloud_url}{url_path}"

headers = {
    "OCS-APIRequest": "true",
    "accept": "application/json"
}

# Make the GET request
response = requests.put(url, headers=headers, auth=(username, password), json=tbl_data)

The variable tbl_data in the above code yields:

{
  "data": {
    "columnId": 31,
    "value": 3333
  }
}

Executing the API call returns an error:
InternalError Column with id 0 is not part of table with id 5

I’ve tried every which way to update using API. Can you please look at the code or give an example how to update a record within Tables App? Thank you in advance for your time spent looking at this.

HOT DIGGITY! Figured it out.

The correct data structure for updating a field value in a particular row.

{
    "viewId: 0,
    "data":{
        "31" : 1111
    }
}

What was throwing me off was the “viewId” key. Since we are not working with specific “Views”, this value can remain 0. But the schema must have it. I was thinking it needs to be replaced with “columnId” or something. Your columnId is in the normal data: structure (31). So for whoever is interested the working code is such:

import requests
import json

username = "XXX"
password = "XXXXXXXX" 
nextcloud_url = "https://your.nextcloud.domain"
# Define the API endpoint and headers
url_path = "/index.php/apps/tables/api/1/rows/41" #Row  
data = {"viewId":0, 
        "data": {
             "31":1111
        }
}

url = f"{nextcloud_url}{url_path}"

headers = {
    "OCS-APIRequest": "true",
    "accept": "application/json"
}

# Make the PUT request
response = requests.put(url, headers=headers, auth=(username, password), json=data)

# Check the response
if response.status_code == 200:
    tables_data = response.json()
    print(json.dumps(tables_data, indent=2))
else:
    print(f"Error: {response.status_code} - {response.text}")

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