Matteo Calò
Matteo Calò

Reputation: 351

How to retrieve versioned document's content in Alfresco by REST API?

Is there a way to retrieve versioned content of document? Possibly by native Alfresco's REST API.

Upvotes: 0

Views: 676

Answers (2)

Jeff Potts
Jeff Potts

Reputation: 10538

The answer given by Matteo Calò is technically correct. That API does exist and it does what he says. However, that endpoint is marked with "limited support" which means you should be cautious when using it. Instead, you should prefer API's marked "PUBLIC" or use standards-based API's like CMIS, which Alfresco supports.

The CMIS browser binding can be used to get an object's content like this: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/test/test.txt

Its properties like this: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/test/test.txt?cmisselector=object

And its versions like this: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/test/test.txt?cmisselector=versions

In this example I'm retrieving the object by path. My test object is in a folder called test and my object's name is test.txt. If, on the other hand, you know the object's ID, you could get its versions like this: http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?cmisselector=versions&objectId=54f47f6f-ee88-4612-8206-ebca8f5b7e6b;3.0

Any time you can use a CMIS URL to give you what you need, you should use it, especially if the alternative is a web script that may not be fully public.

Upvotes: 3

Matteo Calò
Matteo Calò

Reputation: 351

There is follow API: http://HOST:PORT/share/proxy/alfresco/api/version?nodeRef=NODEREF

it returns a list of versions with metadata of NODEREF like this:

[{
  "nodeRef": "versionStore://version2Store/60d3d217-e80b-4066-9e43-6361bb573462",
  "name": "prova1.json",
  "label": "1.11",
  "description": "",
  "createdDate": "08 lug 2016 12:21:49 GMT+0200 (CEST)",
  "createdDateISO": "2016-07-08T12:21:49.843+02:00",
  "creator": {
    "userName": "admin",
    "firstName": "Administrator",
    "lastName": ""
  }
},
{
  "nodeRef": "versionStore://version2Store/a1b38d5e-2556-416a-908e-180687d3ff8c",
  "name": "prova1.json",
  "label": "1.10",
  "description": "",
  "createdDate": "07 lug 2016 13:20:44 GMT+0200 (CEST)",
  "createdDateISO": "2016-07-07T13:20:44.804+02:00",
  "creator": {
    "userName": "admin",
    "firstName": "Administrator",
    "lastName": ""
  }
}]

Upvotes: 1

Related Questions