BatchCreateTableRows
The BatchCreateTableRows API can be used to append a batch of rows to the end of a table.
To find more details about using this API check the BatchCreateTableRows API Reference page.
The following example demonstrates using BatchCreateTableRows API to add two rows at the end of a table.
Replace <workbook-id>
with your workbook id and
<table-id>
with the table id from the response of ListTables API call.
Note:
-
This API takes
batchItemId
in the input. This is an identifier that you can assign to that particular row so that you can link the row id in the response with the item in the request. -
The
cellsToCreate
map needs the ids of the columns in the table. You can get these ids from the ListTableColumns API response. -
The column
Change
has a column level formula. So it does not need to be included in the input as the column formula will be automatically applied to the new rows. You can include the column in the input if you want to override the column formula for the new rows with a different value.
AWS CLI Example
aws honeycode batch-create-table-rows \ --workbook-id "<workboook-id>" \ --table-id "<table-id>" \ --rows-to-create '[ { "batchItemId": "item-001", "cellsToCreate": { "<symbol-column-id>": { "fact": "AAA" }, "<price-column-id>": { "fact": "23.47" }, "<previous-price-column-id>": { "fact": "27.27" }, "<last-updated-column-id>": { "fact": "11/5/20 6:00 PM" } } }, { "batchItemId": "item-002", "cellsToCreate": { "<symbol-column-id>": { "fact": "BBB" }, "<price-column-id>": { "fact": "108" }, "<previous-price-column-id>": { "fact": "127.2" }, "<last-updated-column-id>": { "fact": "11/5/20 6:00 PM" } } } ]'
Python SDK Example
def create_row_data(batch_item_id, symbol, price, previous_price, last_updated): return { "batchItemId": batch_item_id, "cellsToCreate": { "<symbol-column-id>": { "fact": symbol }, "<price-column-id>": { "fact": price }, "<previous-price-column-id>": { "fact": previous_price}, "<last-updated-column-id>": { "fact": last_updated } } } response = honeycode_client.batch_create_table_rows( workbookId = '<workbook-id>', tableId = '<table-id>', rowsToCreate = [ create_row_data("item-001", "AAA", "23.47", "27.27", "11/5/20 6:00 PM"), create_row_data("item-002", "BBB", "108", "127.2", "11/5/20 6:00 PM") ])
Response
{ "createdRows": { "item-001": "<aaa-row-id>", "item-002": "<bbb-row-id>" }, "workbookCursor": 1288497196 }
After the rows are inserted, this is how the table looks:
