How to Update Documents

→ "Try it out - API Component "YADB"
→ check GitHub Python calls | Java Script calls | Java calls | Postman collection

This "How to" describes how to update documents (objects) in your schema using yuuvis® Ultimate operations.

Updating Documents

Updating Metadata

To update the metadata of a stored document (object), you send a POST request to the URL /dms-core/objects/{objectId} with the new metadata values in its body ("POST update document metadata by ID" endpoint.) Note that instead of using a multipart body, the new metadata is passed to the body as a string and designated as media type JSON.

Updating Metadata
Request updateMetadataRequest = new Request.Builder()
        .header("Ocp-Apim-Subscription-Key", key)
        .url(baseUrl + "/dms-core/objects/" + objectId)
        .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"),
			new File("./src/main/resources/metaData2.json")))

The response returns the full, modified metadata with a new version number.

Most of the system properties cannot be updated or are updated automatically. If the new metadata contains these properties, their values must match the values of the current version. Hence you can retrieve the current metadata using the "GET document metadata by ID" endpoint first, to use the result. Edit some properties and post it again using this endpoint.

Updating Content

To update the content file of a stored document (object), you send a POST request to the URL /dms-core/objects/{objectId}/contents/file with the new content file in its body ("POST update document content by ID" endpoint). Specify the file name of the content file via the Content-Disposition header.

Updating Content
Request updateContentRequest = new Request.Builder()
        .header("Ocp-Apim-Subscription-Key", key)
        .header("Content-Disposition", "attachment; filename=\"test2.txt\"")
        .url(baseUrl + "/dms-core/objects/" + objectId + "/contents/file")
        .post(RequestBody.create(MediaType.parse("text/plain; charset=utf-8"), 
			new File("./src/main/resources/test2.txt")))


Status Code Meaning
200 OK
401 Unauthorized
422 Invalid Request Body


Each time you update either the content file or the metadata of a stored document (object), a new version is created. The endpoints for fetching metadata (/dms-core/objects/{objectId}) or content files (/dms-core/objects/{objectId}/contents/file) always return the current version. Check out the following options to get a content file or metadata related to an older version.

Retrieving Version Related Metadata

To retrieve metadata of a version, you send a GET request to the URL /dms-core/objects/{objectId}/versions/{versionNr} ("Get document metadata by ID (specified version)" endpoint). The versionNr for each object starts at 1 and is incremented with each update.

Get Metadata of Version 1
Request versionMetadataRequest = new Request.Builder()
        .header("Ocp-Apim-Subscription-Key", key)
        .url(baseUrl+ "/dms/objects/" + objectId + "/versions/1")

Retrieving Version Related Content

To retrieve the content file of a version, you send a GET request to the URL /dms-core/objects/{objectId}/versions/{versionNr}/contents/file ("Get document content by ID (specified version)" endpoint.

Get Content File of Version 2
Request versionContentRequest = new Request.Builder()
        .header("Ocp-Apim-Subscription-Key", key)
        .url(baseUrl+ "/dms-core/objects/" + objectId + "/versions/2/contents/file")