Self-hosted : I can't get a table record

I’m trying to update a single field in a record within a table

I create the base, then the columns metadata, with the following primary key

            "column_name": "Primary Key",
            "title": "Primary Key",
            "uidt": "ID",
            "dt": "int",
            "un": False,
            "pk": True  # primary key

then I create the table and create the record from some data, using 0 as primary key

Finally, I want to read the record I just created

    def read_table_record(self, primary_key: int) -> dict:
        url = f"{self.host}/api/v2/tables/{self.tableid}/records/{primary_key}"
        return self.session.get(url).json()

But I do get the following:

{‘error’: ‘RECORD_NOT_FOUND’, ‘message’: “Record ‘unknown’ not found”}

Why?

Ps: I double checked, the url resolves properly

Could you please confirm if the record was successfully created? Are you able to see created record with ID set to 0 on the NocoDB UI?


I was able to create a table with specified configuration. And insert a record with ID set to 0 & retrieve it using read record API

Can you help us with your base information? I had tried it out in cloud (PG as root DB). You can copy your base info from here

I tried couple of scenarios and not able to reproduce the issue. And from error it looks like the is id getting passed as unknown so double check the is passing and try with hardcoded id value.

If you are still facing issue with id value 0 then share the table details and database information. And possibly share a sample curl request or code without any dynamic part.

I don’t know what happened, but now read_table_record works flawless

However now I’ve got the same issue trying to update the given record (pk = 0)

        record = self.read_table_record(pk)
        if 'CreatedAt' in record:
            del record['CreatedAt']
        if 'UpdatedAt' in record:
            del record['UpdatedAt']
        if key == 'Primary Key':
            raise ValueError("Primary Key is not overridable")
        record[key] = value
        res = self.update(record)

where

    def update(self, data):
        url = f"{self.host}/api/v2/tables/{self.tableid}/records"
        res = self.session.patch(url, json=data).json()
        return res

Url looks fine, data as well, primary key is there, I just changed one single field value

Base info:

Node: v18.5.0
Arch: x64
Platform: linux
Docker: false
RootDB: pg
PackageVersion: 0.255.0

Changed to data=data in update and now I get

{‘error’: ‘RECORD_NOT_FOUND’, ‘message’: “Record ‘0___[object Object]’ not found”}

We found the bug related update api and made a fix in following PR - Nc fix: Miscellaneous bugs by pranavxc · Pull Request #9348 · nocodb/nocodb · GitHub

You can try following pr build to verify the fix.

docker run -d -p 8888:8080 nocodb/nocodb-timely:0.255.0-pr-9348-20240827-1012

1 Like