logo
開發者文件
搜尋
新增資料表資料

新增資料表資料

此 API 支援一次性向指定 Agent 的資料表新增最多 1000 筆資料,供對話中的操作與查詢使用。

注意

  • 開啟「唯一」的欄位,其值長度不得超過 256 個字元
  • 未開啟「唯一」的欄位,其值長度不得超過 4294967295 個字元(實際受網路狀況影響,建議控制資料長度)。
  • 透過 API 傳輸的資料會轉換為 CSV 格式,CSV 檔案大小不得超過 10 MB,建議控制在此範圍內。

請求方法

POST

端點

https://api-${endpoint}.gptbots.ai/v1/database/import/records

認證

您可以參考 API 概覽,瞭解認證方法。

請求

請求範例

curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/database/import/records' \ -H 'Authorization: Bearer ${API Key}' \ -H 'Content-Type: application/json' \ -d '{ "table_id": "673af861ed69656ac0895b07", "records": [ { "id": "7424489", "name": "4455566777777" }, { "id": "7852549", "name": "446656677665" } ] }'
                      
                      curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/database/import/records' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
    "table_id": "673af861ed69656ac0895b07",
    "records": [
        {
                "id": "7424489",
                "name": "4455566777777"
        }, 
        {
                "id": "7852549",
                "name": "446656677665"
        }
    ]
}'

                    
此代碼塊在浮窗中顯示

請求標頭

欄位 類型 描述
Authorization Bearer ${API Key} 使用 Authorization: Bearer ${API Key} 進行認證。API Key 可於 API Key 頁面取得。
Content-Type application/json 資料類型,請設為 application/json。

重要

  • 當資料表中存在「唯一」欄位時,所有唯一欄位都必須包含在資料中。
  • 唯一欄位的值不得重複、為空或已存在於資料庫中,否則將發生錯誤且資料會被捨棄。

請求內容

欄位 類型 必填 描述
records list 要匯入的資料集合。
table_id string 資料表 ID。

回應

回應範例

"673e9cda9f7bc178002dbd9c"
                      
                      "673e9cda9f7bc178002dbd9c"

                    
此代碼塊在浮窗中顯示

成功回應

欄位 類型 描述
code int 訊息類型代碼。
message string 訊息描述。
data object 本次資料表新增作業的任務 ID,僅回傳一組 ID。

失敗回應

欄位 類型 描述
code int 錯誤代碼。
message string 錯誤訊息。

錯誤代碼

錯誤代碼 訊息
40000 參數錯誤
50000 系統內部錯誤