IBM Support

How to retrieve or add data from/to a data table with API

How To


Summary

How to retrieve or add data from/to a data table with API

Steps

This article provides sample scripts about how to manipulate data table data via integration application such as resilient-circuits scripts and email connector.

Assume the table name is task_duration, which has columns:

API name: task_id; Type: Text

API name: task_name; Type: Text

API name: task_duration; Type: Number

Get the table data in resilient_circuits script:

inc_id = event.message["incident"]["id"]
datatable = self.rest_client().get("/incidents/{}/table_data/task_table?handle_format=names".format(inc_id))
for table_row in datatable["rows"]:

table_row = table_row["cells"]
task_id = table_row.get('task_id').get('value')
task_name = table_row.get('task_name').get('value')
duration = table_row.get('task_duration').get('value')

Add a new data table row in resilient_circuits script:

inc_id = event.message["incident"]["id"]
row = {"cells":{}};
row["cells"]["task_id"] = {"value": "12345"};
row["cells"]["task_name"] = {"value": "Test Task"};
row["cells"]["task_duration"] = {"value": 10);
self.rest_client().post(""/incidents/{}/table_data/task_table/row_data/?handle_format=names".format(inc_id), row);

Delete one or more rows in a data table in resilient_circuits script:

inc_id = event.message["incident"]["id"]
datatable = self.rest_client().get("/incidents/{}/table_data/task_table".format(inc_id))

for table_row in datatable["rows"]:
row_id = table_row['id']
client.delete("/incidents/{}/table_data/task_table/row_data/{}".format(inc_id,row_id))

Delete all rows in a data table in resilient_circuits script:

inc_id = event.message["incident"]["id"]
datatable = self.rest_client().
delete("/incidents/{}/table_data/task_table/row_data".format(inc_id))

Update one or more rows in a data table in resilient_circuits script:

inc_id = event.message["incident"]["id"]
datatable = self.rest_client().get("/incidents/{}/table_data/task_table?handle_format=names".format(inc_id))

for table_row in datatable["rows"]:
row_id = table_row['id']
table_row['cells']['task_name']['value'] = "new value"
self.rest_client().put("/incidents/{}/table_data/task_table/row_data/{}".format(inc_id,row_id),table_row)

Get all rows of a data table via outbound email connector:

<#assign data_table=restClient.get("incidents/" + incident.id?c + "/table_data/task_table?handle_format=names")>
<#list data_table.rows as r>
<tr><td>Table row:</td><td>${r.cells.task_id.value!"-"} </td><td>${r.cells.table_name.value!"-"}</td><td>${r.cells.task_duration.value!"-"} </td></tr>

Document Location

Worldwide

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSIP9Q","label":"IBM Security SOAR"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB24","label":"Security Software"}}]

Document Information

Modified date:
19 April 2021

UID

ibm11160764