Table Operations with REST API
Overview
Tables
are powerful field types that help users view multiple data entries at a glance. Although Tables are easy to control via the browser's UI, they can be tricky to manage when adjusting the data with REST API.
This article introduces techniques for updating Table fields with the REST API.
Prepare a Sample App
Create an App with the following fields and settings.
| Field Type | Field Name | Field Code | Notes |
|---|---|---|---|
| Table | To Do Table | to_do_table | Place the following Text and Radio Button fields inside. |
| Text | Task | table_task | |
| Radio Button | Status | table_radio | Choices: Not Started, In Progress, Done |
The form should look like the following image:
After creating the App, add some sample data.
Retrieve the Record data and Check the Table Structure
The
Get Record
or
Get Records
REST APIs can be used to check how the Table data is structured.
Understanding the structure will help make later REST API operations with Tables clearer.
The following image shows a sample response from the Get Record API.
A detailed example of the response is as follows. Record values are returned in JSON format.
Notice how, that for every row of the table to_do_table, there is an id property. This id is the unique row ID for the row of the Table. The behavior of the REST APIs that are later introduced in this article, changes depending on whether row IDs are included in request.
|
|
Update Table Data
Table rows can be added, updated, and deleted using REST API. These operations all use the Update Record and Update Records API.
The format of the record object in the request changes depending on the operation.
The following sections explain each case.
Add a Row to the Table
The following sample request adds a new row at the beginning of the Table.
As the other rows don't need to be modified, just their row IDs are stated in the request.
Sample data to add:
- Research new AI tools / Not Started
|
|
Update Fields in the Table Row
For each Table row, specify the row IDs and fields be updated.
Fields that do not need to be updated are omitted.
Sample data to update:
- Row ID 9604: Create article A / Not Started → Review article A / Not Started
- Row ID 9605: Create article B / Not Started → Create article B / In Progress
|
|
Replace All Table Data
If Table data is specified without row IDs, all existing rows are deleted.
The data in the request is then added to the Table.
Sample data to replace:
- Create article C / In Progress
- Create article D / In Progress
|
|
Delete Table Rows
If existing row IDs are omitted from the request, those rows are deleted.
Sample data to delete:
- Row ID 9615: Create article A / Not Started (keep)
- Row ID 9616:
Create article B / Not Started(delete)
|
|
Delete All Table Rows
To delete all rows, set "value": [] for the Table.
|
|
Notes
- If a nonexistent row ID is specified, no error occurs. The row is treated as a new row. The row ID of the new row will be unrelated to the row ID specified in the request.
- Existing rows that are not specified in the request are deleted.
- If the field values of existing rows do not need to be updated, include just the existing row ID. The values of those rows can be omitted.