Skip to main content

Document Content Query

💡 API calls require authentication. Refer to Interface Authentication for authentication

API Interface

POST {apiPrefix}/content/query

Submit document content query task

  • If task addition fails, the failure reason is returned synchronously
  • If task addition succeeds, the task ID is returned synchronously. Third parties can configure task callback notifications to get task status.

Request Body

Content-Type is application/json

Parameter NameTypeDescriptionRequired
fileUrlstringFile download addressYes
filenamestringFilename with extensionYes
tokenTypestringThird-party token type, value is cookie or headerNo
tokenValuestringThird-party token value, passed back when zOffice downloads files or callback notificationsNo
callbackstringCallback address. zOffice will callback to notify status after task completionYes
opsarrayOrdered operation array for document content queries, array objects see op description below. Supported operation list see Query ListYes

Request body example

{
"fileUrl": "http://{{thirdparty-demo}}/v2/context/local-PublicAPI-contentUpdate-clearDoc/content",
"filename": "demo-docx.docx",
"tokenType":"cookie",
"tokenValue":"zdocs_access_token={{zdocs_access_token}}",
"callback": "http://{{thirdparty-demo}}/v2/context/convert/callback",
"ops": [ {
"actId": "QueryBookmarkRef",
"options": {
"names": ["Bookmark One", "Bookmark Two"]
}
}]

}

Normal Response:

{
"taskId": "6f6598c8-c87e-420b-b6c4-6f1b187201dc",
"code": "Ok",
"detail": {
"taskStatus": "IN_QUEUE"
}
}

Error Response:

{
"taskId": "695fbf6e-90d2-42ba-83d5-00e81e5e366e",
"code": "TaskQueueCongestion",
"detail": {
"taskStatus": "FAIL"
}
}

Query List

Query Bookmark Area Content

Source file types support doc/docx/wps Source file maximum 300M

{
"actId": "QueryBookmarkRef",
"options": {
"names": ["Bookmark One", "Bookmark Two"]
}
}

options Description

Option NameOption TypeRequiredDescription
namesstring[]YesArray containing bookmark names

Download result:

{
"Bookmark One": "Bookmark One Area Content",
"Bookmark Two": "Bookmark Two Area Content"
}

Note: Bookmarks that do not exist in the document will not appear in the result

Query Document Restrict Editing Status

Source file types support doc/docx/wps Source file maximum 300M

{
"actId": "QueryRestrictEditing",
"options": {}
}

Download result:

{
"enforcement": true,
"edit": "READ_ONLY"
}
Option NameOption TypeRequiredDescription
enforcementbooleanYesWhether restrict editing is enabled
editstringNoRestrict editing type, values are READ_ONLY | ALLOW_ONLY_REVISIONS | ALLOW_ONLY_COMMENTS | ALLOW_ONLY_FORM_FIELDS

Query Document Revision Count

Source file types support doc/docx/wps Source file maximum 300M

{
"actId": "QueryRevisionsCount",
}

Download result:

{
"revisionsCount": 1
}
Option NameOption TypeRequiredDescription
revisionsCountintYesRevision count

Query Document Comments

Source file types support doc/docx/wps/xls/xlsx Source file maximum 300M, xlsx format 600M

{
"actId": "QueryComments",
}

Download result:

{
"commentsCount": 2,
"unresolvedCommentsCount": 1,
"comments": [{
"authorName": "Author",
"creationTime": 1724055042162,
"resolved": true,
"content": "Text",
"replies": [{...}] //Reply comments
}]
}
Option NameOption TypeRequiredDescription
commentsCountintYesComment count
unresolvedCommentsCountintYesUnresolved comment count
commentsarrayYesComment information array

Note: Reply comments are not counted in the count.

Comment Information:

Option NameOption TypeRequiredDescription
authorNamestringYesAuthor name
creationTimenumberYesCreation timestamp
resolvedbooleanYesWhether resolved
contentstringYesComment content
repliesarrayNoReply comment array (fields same as comment information)

Note: The resolved attribute of reply comments has no meaning, please focus on the resolved attribute of the main comment.