# 说明
将项目中已有的文档、文档目录或 Wiki 关联到需求、缺陷或任务。对应内部接口 /api/entity/attachments/relate_document,只写关联关系,不拷贝文件。
# url
https://api.tapd.cn/attachments/relate_document
# 支持格式
JSON/XML(默认JSON格式)
# HTTP请求方式
POST
# 请求数限制
一次只能创建一条关联关系
# 请求参数
| 字段名 | 必选 | 类型及范围 | 说明 |
|---|---|---|---|
| workspace_id | 是 | integer | 业务对象所属项目ID |
| entity_id | 是 | integer | 业务对象ID(需求 / 缺陷 / 任务) |
| relate_entry_id | 是 | integer | 关联的文档 / 文档目录 / Wiki ID |
| entity_type | 否 | string | 业务对象类型,取值:story(默认)、bug、task |
| relate_type | 否 | string | 关联类型,取值:Document(文档,默认)、DocumentFolder(文档目录)、Wiki |
| selected_workspace_id | 否 | integer | 被关联文档 / Wiki 所属项目ID,默认与 workspace_id 相同。Wiki 支持跨项目关联时需要传入 |
| current_user | 否 | string | 操作人昵称。Basic Auth 调用时建议传入,用于记录关联创建人 |
# 调用示例及返回结果
# 关联文档到需求
# curl 使用 Basic Auth 鉴权调用示例
curl -u 'api_user:api_password' -d 'workspace_id=10104801&entity_id=1010104801854919725&entity_type=story&relate_entry_id=1010104801000001234&relate_type=Document¤t_user=someone' 'https://api.tapd.cn/attachments/relate_document'
# 返回结果
{
"status": 1,
"data": {
"attachment_id": "1010104801000005678",
"success": 1
},
"info": "success"
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 返回结果字段说明
| 字段 | 说明 |
|---|---|
| attachment_id | 关联关系记录ID。若该文档此前已关联到同一对象,则返回已有关联记录ID |
| success | 是否成功,成功为 1 |
← 获取附件 获取单个附件下载链接 →