Query the connector database¶
Lists the databases accessible by a structured connector. Start by looking at the browsable connectors and get the connector ID and source type from the available entries.
POST https://moi.matrixorigin.cn/newmoi/connectors/structured/v1/source/databases
Preparation before calling¶
First View browsable connectors, select the entry with enabled as true and capabilities.list_databases as true. 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 theX-API-KeyHeader.$WORKSPACE_ID: The workspace ID to be queried, passed through theX-Workspace-IDHeader.$CONNECTOR_IDand$SOURCE_TYPE: View the connector ID and source type returned by the browsable connector interface; both must come from the same return record.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/connectors/structured/v1/source/databases" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"connector_id\": \"$CONNECTOR_ID\",
\"source_type\": \"$SOURCE_TYPE\"
}"
Request body¶
Field |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
The saved connector ID. |
|
string |
Yes |
A structured source type. |
[] after a type denotes an array. [] in a field path denotes each item in an array.
Successful response¶
Returns 200 on success.
{
"code": "OK",
"msg": "OK",
"data": {
"databases": [
{
"name": "sales",
"display_name": "sales"
}
],
"endpoint_results": []
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object[] |
Database reference. |
|
string |
Database name, this value will be used for subsequent requests to |
|
string |
Database name used for display. |
|
JSON[] |
Currently returns an empty array. |
[] after a type means an array. For example, string[] is an array of strings.
Error response¶
{
"code": "ErrParamInvalid",
"msg": "invalid parameter",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
Field is missing, or |
Use the |
|
|
The current service does not provide structured data source discovery. |
This group of interfaces is temporarily unavailable. |
|
|
The structured data source feature is not enabled in the current workspace. |
Check if this feature is available for this workspace. |
|
|
MongoDB structured discovery is not enabled for the current workspace. |
Do not continue calling the MongoDB connector’s discovery interface. |
|
|
The service failed to list the database. |
Keep the desensitization error message and try again. |
Follow-up operations¶
If the capabilities.list_schemas of the selected connector is available, continue Get database classification; otherwise, directly Query connector table. When requesting, bring the database ID obtained in this step.