Skip to content

添加全文评论

在文档中添加一条全局评论,不支持局部评论。

请求

项目
HTTP URLhttps://open.feishu.cn/open-apis/drive/v1/files/:file_token/comments
HTTP MethodPOST
接口频率限制1000 次/分钟、50 次/秒
支持的应用类型custom,isv
权限要求 调用该 API 所需的权限。开启其中任意一项权限即可调用 开启任一权限即可docs:doc 查看、评论、编辑和管理文档 docs:doc:readonly 查看、评论和导出文档 docs:document.comment:create 添加、回复云文档中的评论 docs:document.comment:write_only 回复、修改、删除云文档中的评论 drive:drive 查看、评论、编辑和管理云空间中所有文件 drive:drive:readonly 查看、评论和下载云空间中所有文件 sheets:spreadsheet 查看、评论、编辑和管理电子表格 sheets:spreadsheet:readonly 查看、评论和导出电子表格
字段权限要求> Tip: 该接口返回体中存在下列敏感字段,仅当开启对应的权限后才会返回;如果无需获取这些字段,则不建议申请 contact:user.employee_id:readonly 获取用户 user ID

请求头

名称类型必填描述
Authorizationstringtenant_access_tokenuser_access_token 值格式:"Bearer access_token" 示例值:"Bearer u-7f1bcd13fc57d46bac21793a18e560" 了解更多:如何选择与获取 access token
Content-Typestring固定值:"application/json; charset=utf-8"

路径参数

名称类型描述
file_tokenstring文档 Token
可以通过浏览器该文档的 URL 栏上直接获取文档 Token 。
示例值:"XIHSdYSI7oMEU1xrsnxc8fabcef"

查询参数

名称类型必填描述
file_typestring云文档类型
示例值:doc
可选值有
- doc: 旧版文档,已不推荐使用 - docx: 新版文档
user_id_typestring用户 ID 类型
示例值:open_id
可选值有
- open_id: 标识一个用户在某个应用中的身份。同一个用户在不同应用中的 Open ID 不同。了解更多:如何获取 Open ID - union_id: 标识一个用户在某个应用开发商下的身份。同一用户在同一开发商下的应用中的 Union ID 是相同的,在不同开发商下的应用中的 Union ID 是不同的。通过 Union ID,应用开发商可以把同个用户在多个应用中的身份关联起来。了解更多:如何获取 Union ID? - user_id: 标识一个用户在某个租户内的身份。同一个用户在租户 A 和租户 B 内的 User ID 是不同的。在同一个租户内,一个用户的 User ID 在所有应用(包括商店应用)中都保持一致。User ID 主要用于在不同的应用间打通用户数据。了解更多:如何获取 User ID?
默认值open_id
当值为 user_id,字段权限要求contact:user.employee_id:readonly 获取用户 user ID

请求体

名称类型必填描述
reply_listreply_list评论里的回复列表
  └ repliesfile.comment.reply\[\]回复列表
    └ contentreply_content回复内容
      └ elementsreply_element\[\]回复内容的元素列表
        └ typestring回复内容的元素类型
示例值:"text_run"
可选值有
- text_run: 普通文本 - docs_link: 云文档链接 - person: at 联系人
        └ text_runtext_run普通文本
          └ textstring添加普通文本
示例值:"comment text"
        └ docs_linkdocs_link云文档链接
          └ urlstring添加云文档链接
示例值:"https://example.feishu.cn/docs/doccnHh7U87HOFpii5u5Gabcef"
        └ personpersonat 联系人
          └ user_idstring添加用户的 user_id 以@用户
示例值:"ou_cc19b2bfb93f8a44db4b4d6eababcef"

请求体示例

json
{
    "reply_list": {
        "replies": [
            {
                "content": {
                    "elements": [
                        {
                            "type": "text_run",
                            "text_run": {
                                "text": "comment text"
                            },
                            "docs_link": {
                                "url": "https://example.feishu.cn/docs/doccnHh7U87HOFpii5u5Gabcef"
                            },
                            "person": {
                                "user_id": "ou_cc19b2bfb93f8a44db4b4d6eababcef"
                            }
                        }
                    ]
                }
            }
        ]
    }
}

响应

响应体

名称类型描述
codeint错误码,非 0 表示失败
msgstring错误描述
datafile.comment-
  └ comment_idstring评论 ID(创建新评论可不填;如填写,则视为回复已有评论)
  └ user_idstring用户 ID
  └ create_timeint创建时间
  └ update_timeint更新时间
  └ is_solvedboolean是否已解决
  └ solved_timeint解决评论时间
  └ solver_user_idstring解决评论者的用户 ID
  └ has_moreboolean是否还有更多项
  └ page_tokenstring分页标记,当 has_more 为 true 时,会同时返回新的 page_token,否则不返回 page_token
  └ is_wholeboolean是否是全文评论(本接口不返回该参数)
  └ quotestring局部评论的引用字段(本接口不返回该参数)
  └ reply_listreply_list评论里的回复列表
    └ repliesfile.comment.reply\[\]回复列表
      └ contentreply_content回复内容
        └ elementsreply_element\[\]回复的内容
          └ typestring回复的内容元素
可选值有
- text_run: 普通文本 - docs_link: at 云文档链接 - person: at 联系人
          └ text_runtext_run文本内容
            └ textstring回复 普通文本
          └ docs_linkdocs_link文本内容
            └ urlstring回复 at 云文档
          └ personperson文本内容
            └ user_idstring回复 at 联系人
      └ reply_idstring回复 ID
      └ user_idstring用户 ID
      └ create_timeint创建时间
      └ update_timeint更新时间
      └ extrareply_extra回复的其他内容,图片 Token 等
        └ image_liststring\[\]评论中的图片 Token list

响应体示例

json
{
    "code": 0,
    "msg": "success",
    "data": {
        "comment_id": "6916106822734512356",
        "user_id": "ou_cc19b2bfb93f8a44db4b4d6eababcef",
        "create_time": 1610281603,
        "update_time": 1610281603,
        "is_solved": false,
        "solved_time": 1610281603,
        "solver_user_id": "null",
        "has_more": false,
        "page_token": "6916106822734512356",
        "is_whole": true,
        "quote": "划词评论引用内容",
        "reply_list": {
            "replies": [
                {
                    "content": {
                        "elements": [
                            {
                                "type": "text_run",
                                "text_run": {
                                    "text": "comment text"
                                },
                                "docs_link": {
                                    "url": "https://example.feishu.cn/docs/doccnHh7U87HOFpii5u5Gabcef"
                                },
                                "person": {
                                    "user_id": "ou_cc19b2bfb93f8a44db4b4d6eababcef"
                                }
                            }
                        ]
                    },
                    "reply_id": "6916106822734512356",
                    "user_id": "ou_cc19b2bfb93f8a44db4b4d6eab2abcef",
                    "create_time": 1610281603,
                    "update_time": 1610281603,
                    "extra": {
                        "image_list": [
                            "xfsfseewewabcef"
                        ]
                    }
                }
            ]
        }
    }
}

错误码

HTTP状态码错误码描述排查建议
4001069301fail重试,若稳定失败请联系相关业务方oncall人员
4001069302param error检查参数有效性
4031069303forbidden检查是否有待评论云文档的评论权限
4001069304docs had been deleted检查待评论云文档是否已被删除
4001069305docs not exist检查待评论云文档是否能正常访问
4001069306content review not pass排查评论内容是否存在不合法内容
4041069307not exist检查待评论云文档是否能正常访问、检查评论内容at人或云文档是否存在
4001069308exceeded limit评论数据超过上限限制,详情请咨询客服
4001069399internal error重试,若稳定失败请联系相关业务方oncall人员

内容来源:飞书开放平台 · 自动爬取整理