Rows endpoint may return keys or values

Hi,

I’m running into a strange behaviour when querying single select columns through the rows endpoint in the API (on cloud.seatable.io): sometimes it returns the technical ids, sometimes the values of the single select options.

Here is the method to reproduce the behaviour: We create the simple table in the following screenshot

However,

  • for SP1: create the single select options by Hand
  • for SP2: create the options by importing this json file:
[
  {
    "name": "A",
    "id": 666,
    "color": "#F4667C",
    "textColor": "#FFFFFF",
    "borderColor": ""
  }
]

Then fill one line with data.

When I now query the content of the table with
curl -H 'Authorization: Token <token>' 'https://cloud.seatable.io/dtable-server/api/v1/dtables/<base>/rows/?table_id=<table_id>'
I get

{
  "rows": [
    {
      "_creator": "....",
      "_ctime": "2023-03-17T13:56:57.962Z",
      "_mtime": "2023-03-17T13:57:01.713Z",
      "_id": "CViDr0YNTnC4wgu4phirIA",
      "Name": "0001",
      "SP1": "Z",
      "SP2": 666,
      "_locked": null,
      "_locked_by": null,
      "_archived": false,
      "_last_modifier": "...."
    }
  ]
}

Here “SP1” shows the value, “SP2” shows the id.

However, this difference is not visible from the metadata of the columns:

          {
            "key": "AM3S",
            "type": "single-select",
            "name": "SP1",
            "editable": true,
            "width": 200,
            "resizable": true,
            "draggable": true,
            "data": {
              "enable_fill_default_value": false,
              "default_value": null,
              "options": [
                {
                  "name": "Z",
                  "color": "#ADDF84",
                  "textColor": "#FFFFFF",
                  "borderColor": "#9CCF72",
                  "id": "67908"
                }
              ]
            },
            "permission_type": "",
            "permitted_users": [],
            "edit_metadata_permission_type": "",
            "edit_metadata_permitted_users": [],
            "description": null
          },
          {
            "key": "lJLW",
            "type": "single-select",
            "name": "SP2",
            "editable": true,
            "width": 200,
            "resizable": true,
            "draggable": true,
            "data": {
              "enable_fill_default_value": false,
              "default_value": null,
              "options": [
                {
                  "name": "A",
                  "id": 666,
                  "color": "#F4667C",
                  "textColor": "#FFFFFF",
                  "borderColor": ""
                }
              ]
            },
            "permission_type": "",
            "permitted_users": [],
            "edit_metadata_permission_type": "",
            "edit_metadata_permitted_users": [],
            "description": null
          }

So what is the difference between the two columns? And how can detect it from the API in order to know, when to translate ids?

Good question! We’ll get back to you.

The id in your JSON file should be a string and not an integer. Then it should as expected and always show the name.

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