Problem with adding row with api

Hello

I have problem with request to add row i table. After POST reuest /index.php/apps/tables/api/1/tables/10/rows the response is:
“message”: “Column with id 0 is not part of table with id 10”

What’s wrong?

Hello,

I also get this message trying to add a new row via POST-Request.
The message is referring to
“colum with id 0”
allthough id 0 isn’t part of my request.

My data structure looks like this:

data ={
    "tableId": 11,
    "createdBy": "user",
    "createdAt": "2023-04-01 09:20:42",
    "lastEditBy": "user",
    "lastEditAt": "2023-04-01 09:20:42",
    "data": 
        {
        "columnId": 101,
        "value": {"Col1": "Tiger"} 
        }
}

Is there an error in my structure or could this be an API internal related issue?

I checked tableId and columnId. They are correct. GET request work just fine.

Maybe API documentation differs from actual requirements? Could 0 be used as default columnId value?

I am running tables V0.7 beta2 and used OCS API Viewer and Python for testing. Both ways leading to the same result.

Did others run into this message as well?

Hello,

I got the same error, too.

I did manage to perform all CRUD operations on Tables API from python. :white_check_mark:

Creation and Update data format is not so well documented on APIv1. :smirk:

« Data as key - value store »

How make it work in OCS API Viewer?

May be the Tables app is too joung?

The actual accepted data JSON to send format is: (mapped column id ==> data :woman_shrugging:)

data ={
    "data": 
        {
          "23": "Ivan",
          "24": "Dutest",
          "25": "ivan@invalid.email"
        }

}

:point_right:seen here

php code also duplicated here (Create/insert) :woman_shrugging: Seem joung code to me…

I’m currently developping a PoC on this Tables API for a project.

I could publish the python wrapper library under LGPL would you be intersted?

full working code:

EDIT :

import requests
import json
from dotenv import load_dotenv
import os

load_dotenv()  # take environment variables from .env.
username = "admin"
password = os.getenv('ADMIN_PASSWORD')
nextcloud_url = os.getenv('NEXTCLOUD_URL')

data ={
    "data":
        {
          "23": "Ivan",
          "24": "Dutest",
          "25": "ivan@invalid.email"
        }
}
tableId = 4
url_path = f"/index.php/apps/tables/api/1/tables/{tableId}/rows"
response = requests.post(
    f"{nextcloud_url}{url_path}",
    headers={
        "OCS-APIRequest": "true",
        'accept': 'application/json',
    },
    auth=(username, password),
    json=data,
    )

print(json.dumps(response.json(), indent=2))