Documentum Rest API

Documentum Rest API

Atif
3 min readOct 30, 2019

Introduction:

Now a days there is a very usual trends to use restful APIs for software product development due to its flexibility of interaction. So its very common to have rest APIs for Documentum server. In this blog I will explain how we can work with Documentum Rest API.

Result Formats:

For Documentum API there are two result formats available e.g. JSON, XML. Most of applications used JSON as default format. We can get response in specific format by adding “content-type” in request for API.

API Calls:

As you know there are following HTTP request types for restful API.

  • GET (Retrieve data)
  • POST (Create data)
  • PUT (Update data)
  • DELETE (Delete data)

GET (Retrieve data)

By generating GET request for API we can get list of Documentum repositories, list of folders or list of documents within a folder.

  • URL to get list of repositories.

[GET] http://HOSTNAME:PORT/dctm-rest/repositories

  • URL to get list of folders

[GET] http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/folders/1211s5488d5e/folders

  • URL to get list of documents within a folder

[GET] http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/folders/1211s5488d5e/documents

GET Request example:

request({
method: 'GET',
uri: 'http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/folders/1211s5488d5e/documents',
auth: {
'user': 'username',
'pass': 'password',
'sendImmediately': false
},
headers: {
"content-type": "application/vnd.emc.documentum+json"
},
function (error, response, body) {
if (error) {
return console.error('upload failed:', error);
}
console.log('Response Body:', body);
})

Above request will have response in JSON as we have add content type.

POST (Create data)

By generating POST request we can create document metadata and upload a file against document object id.

We create metadata and upload document against a folder location.

  • URL to create metadata in a folder.

[POST] http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/folders/525d542w971e/documents

  • URL to upload document content

[POST] http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/objects/1452s87d45de2(document object id)/contents

POST Request examples.

First of all we need to create document metadata and in response we will receive r_object_id which is the unique id of document. That r_object_id will be used to upload document content.

request({
method: 'POST',
uri: 'http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/folders/0c01322b80004318/documents',
auth: {
'user': 'username',
'pass': 'password',
'sendImmediately': false
},
headers: {
"content-type": "application/vnd.emc.documentum+json"
},
body: JSON.stringify(
{"properties":
{"object_name":"Test Doc.pdf",
"r_object_type":"leasing_document",
"a_content_type":"pdf",
}})

},
function (error, response, body) {
if (error) {
return console.error('upload failed:', error);
}
console.log('Response Body:', body);
})

In response lets suppose we received "r_object_id":"14s25d4845s77"

Now we can generate a POST request to upload document content.

var stream;
stream = fs.createReadStream("D:/Test Doc.pdf");
let formData = {
toUpload: {
value:stream,
options: {
filename: 'Test Doc',
contentType: 'pdf'
}
}
};
let options = {
url: "http://HOSTNAME:PORT/dctm- rest/repositories/user_repo/objects/14s25d4845s77/contents",
method: 'POST',
formData: formData,
auth: {
'user': 'username',
'pass': 'password',
'sendImmediately': false
}
}
request(options, function (err, resp, body) {
if (err)
console.log(err);
else{
console.log("File Uploaded"+ body);
}
});

PUT (Update data)

We can generate PUT request to checkout the document. Once a document is checked out it will be locked and we can upload new version of that document.

  • Checkout URL

[PUT] http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/objects/1452s87d45de23/lock

  • Checkout response
{
"rel": "http://identifiers.emc.com/linkrel/checkin-next-major",
"href": "http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/objects/0901322b800ba16f/versions?object-id=0901322b800ba16f&version-policy=next-major"
},
{
"rel": "http://identifiers.emc.com/linkrel/checkin-next-minor",
"href": "http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/objects/0901322b800ba16f/versions?object-id=0901322b800ba16f&version-policy=next-minor"
},
{
"rel": "http://identifiers.emc.com/linkrel/cancel-checkout",
"href": "http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/objects/0901322b800ba16f/lock"
},
  • Cancel-Checkout

We can unlock checked out document by generating DELETE request to above cancel-checkout URL.

DELETE (Delete data)

To remove document and metadata we can generate DELETE request against following URL.

  • Request Example
request({
method: 'DELETE',
uri: 'http://HOSTNAME:PORT/dctm-rest/repositories/user_repo/objects/0901322b800025fe',
auth: {
'user': 'username',
'pass': 'password',
'sendImmediately': false
},
},
function (error, response, body) {
if (error) {
return console.error('Delete failed:', error);
}else{
console.log('Response Body:', body);
}
})

--

--

Atif

Software Engineer | .Net | Azure | Documentum | MERN