Skip to main content

Update table and column type

Update table names and existing column configuration

Request

curl -vvv -X PATCH "$API_HOST/open/api/v1/tablenodes/$table_id/" -H "Authorization: $access-token" -d "projectID=$project_id&name=$name" -F "columns=@$file_path"

Request body form-data example

KeyValueRequiredNote
projectID264YProject ID
nameTable nameN
columnstable1update.jsonNColumns configuration file

Python example

def table_update(access_token, project_id, table_id, name, columns):
data = {
'projectID': project_id,
'name': name
}

files = {
'columns': io.StringIO(json.dumps(columns)),
}

headers = {'Authorization': access_token}
url = '%s/open/api/v1/tablenodes/%d/' % (API_HOST, table_id)
response = requests.patch(url, headers=headers, files=files, data=data)
return response.json()

ws_resp = ma.get_workspace_detail(access_token, workspace)

project = ws_resp['detail']['detail']['projects'][0]
# create table using csv
data = {
'projectID': project['id'],
'name': 'test-csv-upload',
'skipFirstRow': True
}
resp = ma.create_table(access_token, data,
'data/create_table_columns.json',
'data/gd.csv')
table = resp['detail']
resp = ma.read_table(access_token, table['id'], '', '')
columns = resp['detail']['columns']

name_id = [i['id'] for i in resp['detail']['columns'] if i['name'] == 'Name'][0]
columns_new = [
{
'id': name_id,
'name': '名称'
}
]
resp = ma.table_update(access_token, project['id'], table['id'],
'new-table-name', columns_new)

Response

Response body

Description of some key information

NameTypeDescription
detailobject
∟updatedTableNodeobjectTables affected
∟ updatedFieldsobjectTabre property updated
∟ updatedColumnsarrayColumn list updated
∟ columnIDstringColumn ID
∟ updatedFieldsobjectColumn property updated
∟ updatedCellsmapCells updated
∟invalidedColumnsarrayColumns that can't be update succesfully

Response body example

{
"code": 0,
"detail": {
"updatedTableNode": {
"id": 980,
"projectID": 264,
"updatedFields": {
"name": "newName"
}
},
"updatedColumns": [
{
"projectID": 264,
"tableNodeID": 980,
"columnID": "625914457cff69c01aed2d71",
"updatedFields": {
"name": "Title3"
},
"updatedCells":null,
"invalidedColumns": []
},
{
"projectID": 264,
"tableNodeID": 980,
"columnID": "625914457cff69c01aed2d72",
"updatedFields": {
"name": "Region3"
},
"updatedCells":null,
"invalidedColumns": []
},
{
"projectID": 264,
"tableNodeID": 980,
"columnID": "625914457cff69c01aed2d74",
"updatedFields": {
"name": "FAR",
"type": "number",
"typeOptions": {
"precision": 2,
"format": "number"
}
},
"updatedCells": {
"625914457cff69c01aed2d80": {
"625914457cff69c01aed2d74": 2.2
},
"625914457cff69c01aed2d85": {
"625914457cff69c01aed2d74": 2.4
},
"625914fa7cff69c01aed2e43": {
"625914457cff69c01aed2d74": 1.6
},
"625914fa7cff69c01aed2e44": {
"625914457cff69c01aed2d74": 2
},
"625914fa7cff69c01aed2e45": {
"625914457cff69c01aed2d74": 2.18
},
"625931df04b5540935aef0e0": {
"625914457cff69c01aed2d74": 2.5
},
"625931df04b5540935aef0e1": {
"625914457cff69c01aed2d74": 2.9
},
"625931df04b5540935aef0e2": {
"625914457cff69c01aed2d74": 2.4
},
"625931df04b5540935aef0e9": {
"625914457cff69c01aed2d74": 1.8
}
},
"invalidedColumns": []
}
]
},
"extra":null,
"message": "OK",
"requestID":null
}