添加资源到 Session

更新时间:
复制为 MD 格式

此功能为 M3 门控特性,需要先通过 Files API 上传文件获取 file_id

请求头

头部

必选

说明

Authorization

Bearer

Content-Type

application/json

路径参数

参数

类型

必选

说明

session_id

string

Session ID(sess_ 前缀)

请求体

字段

类型

必选

说明

resources

array

资源对象数组

resources[].type

string

取值 "file""github_repository"

resources[].file_id

string

文件 ID(通过 Files API 上传后获得)

示例请求

curl -X POST "https://api.qoder.com.cn/api/v1/cloud/sessions/sess_019e392c0d1e74e095d21ea4c6b41def/resources" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "resources": [
      {"type": "file", "file_id": "file_abc123def456"}
    ]
  }'

示例响应

HTTP 200 OK

返回更新后的 Session 对象(含新的 resources 列表)。

错误码

HTTP

type

触发条件

400

invalid_request_error

请求格式错误(如 type 不为 "file""github_repository",或缺少 file_id

401

authentication_error

PAT 无效或过期

404

not_found_error

Session 或文件不存在

错误响应示例:

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "resources[0]: field 'type' must be one of 'file', 'github_repository'."
  }
}
{
  "type": "error",
  "error": {
    "type": "not_found_error",
    "message": "File 'file_fake_test_id' was not found."
  }
}

完整错误信封说明详见 错误参考