Check if the data source has been added

Checks whether the requested catalog file and table already exist in the knowledge base as a data source. Use this interface to remove duplicates before adding sources.

POST https://moi.matrixorigin.cn/newmoi/semantic-models/{model_id}/sources/existence

Preparation before calling

First confirm the identification of the files and tables to be checked in the Catalog. Prepare a personal access token and target workspace ID that has access to the target workspace.

The example below uses:

  • $AI_STUDIO_API_KEY: The actual personal access token, passed through the X-API-Key Header.

  • $WORKSPACE_ID: Target workspace ID, passed through X-Workspace-ID Header.

  • $MODEL_ID: The knowledge base ID to check.

  • $FILE_ID: Catalog file ID to check.

  • $TABLE_ID: Catalog table ID to check.

Request example

curl -X POST "https://moi.matrixorigin.cn/newmoi/semantic-models/$MODEL_ID/sources/existence" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "file_ids": ["'"$FILE_ID"'"],
    "table_ids": ['"$TABLE_ID"']
  }'

Path parameters

Parameter

Type

Required

Description

model_id

integer

Yes

The knowledge base ID of the data source to be checked.

Request body

Field

Type

Required

Description

file_ids

array[string]

No

The file ID to check.

table_ids

array[integer]

No

The table ID to check.

Successful response

Returns 200 on success, and only returns request IDs that already exist in the knowledge base. Remove these duplicates from the to-be-added list before adding the source.

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "file_ids": ["file_01"],
    "table_ids": [456]
  }
}

The response fields are as follows.

Field

Type

Description

code

string

OK on success.

msg

string

OK on success.

data.file_ids

string[]

Among the requested file IDs, the ID already exists as the source.

data.table_ids

integer[]

The ID of the requested table ID that already exists as a source.

[] after a type means an array. For example, string[] is an array of strings.

Error response

{
  "code": "ErrParamInvalid",
  "msg": "invalid source identifiers",
  "data": null
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

ErrParamInvalid

Invalid model_id, file ID, or table ID.

Correct the request parameters and try again.

401

ErrUnauthorized

The API Key is invalid or has expired.

Check API Key.

403

ErrForbidden

The caller does not have permission to read the source or knowledge base.

Check workspace and object authorization.

404

ErrNotFound

The knowledge base does not exist or is not visible.

Reconfirm model_id.

500

ErrServer

The service failed to check the source.

Keep the desensitized response information and try again.

Follow-up operations

Add data source after removing duplicates.

Last updated on