Preview table data¶
Preview table data without modifying table content.
POST https://api.moi.matrixorigin.cn/v5/catalog/table/preview
Preparation before calling¶
First query the object in the database to obtain the target table ID, or prepare the table name and database positioning parameters. Prepare the personal access token, target workspace ID, and table location information that has access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$TABLE_ID: Table ID to preview.
Request example¶
curl -X POST "https://api.moi.matrixorigin.cn/v5/catalog/table/preview" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"id": '"$TABLE_ID"'
}'
Request body¶
The positioning method of the table is consistent with query table information: pass in id, or pass in name and database_id/database_name.
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Conditionally required |
Table ID. You do not need to pass the name after providing it. |
|
string |
Conditionally required |
Table name; required if |
|
integer |
Conditionally required |
Non-system database ID; mutually exclusive with |
|
string |
Conditionally required |
System database name; mutually exclusive with |
|
integer |
No |
Page number; if it is not transmitted or is less than or equal to |
|
integer |
No |
The number of items per page; use |
|
integer |
No |
Number of preview rows; passing a positive number overwrites |
|
boolean |
No |
Whether to return the total number of rows; return if not transmitted. |
Successful response¶
Returns 200 and preview results on success. The returned fields are consistent with query table data.
{
"code": "OK",
"msg": "OK",
"data": {
"data": [
["1", "100.00"]
],
"columns": [
{
"name": "id",
"type": "INT"
},
{
"name": "amount",
"type": "DECIMAL"
}
],
"page": 1,
"page_size": 100
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
array |
Row data; each inner array is arranged in the order of |
|
array |
Column information, each item contains |
|
integer |
Total number of table rows; only returned when |
|
integer |
Current page number. |
|
integer |
The maximum number of lines per page. |
Error response¶
The following is a generic HTTP 500 error response. Some deployments can also return it when the table is missing. ErrServer does not distinguish a missing table from a service failure. Invalid table location parameters are a separate case from a well-formed ID that does not identify an existing table.
If preview fails, use the same table location parameters to query table information. If that request returns 404, verify the table ID or name and database before previewing again. If the table information is readable but preview still fails, record the HTTP status, response code, and request time and contact support.
{
"code": "ErrServer",
"msg": "Internal server error",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
Invalid table ID, name positioning, or paging parameters. |
Use the table ID, or complete the table name and database location parameters. |
|
|
The current identity does not have table read permission. |
Check workspace and table authorizations. |
|
|
The system database does not support the current read path. |
Use supported table positioning methods instead. |
|
|
The service cannot preview table data. |
Check the table information with the same location parameters. If the table is readable but preview still fails, record the request time and response code and contact support. |
Follow-up operations¶
After completion, Query Catalog details confirms the result.