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
Key | Value | Required | Note |
---|---|---|---|
projectID | 264 | Y | Project ID |
name | Table name | N | |
columns | table1update.json | N | Columns 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
Name | Type | Description |
---|---|---|
detail | object | |
∟updatedTableNode | object | Tables affected |
∟ updatedFields | object | Tabre property updated |
∟ updatedColumns | array | Column list updated |
∟ columnID | string | Column ID |
∟ updatedFields | object | Column property updated |
∟ updatedCells | map | Cells updated |
∟invalidedColumns | array | Columns 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
}