cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve content via REST

matthew_walters
Champ in-the-making
Champ in-the-making
I'd like to retrieve some content via REST but specifying a particular version, or other data

I can get the content
http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Sites/TEST/fragme...

This returns exactly what I want (the content of 'fragment.html'), but I'd like to be able to specify a particular version (or other such metadata), for example return version 1.0 of file or version 1.1 of the file

Is this possible?


I see there's another way of doing this
http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser?cmisaction=query&state... * from cmis:document  where cmis:name='fragment.html'

but it return only the metadata of file 'fragment.html', not the content, and i can't include cmis:versionLabel in the where clause
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
What you're using is CMIS, version 1.1, browser binding. So you can look at the CMIS specification to learn more about what's possible.

Here's a hint, though.

When you go to:
http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Sites/TEST/fragme...


You are asking for the content of an object. It's the same thing you'd get if you were to append "?cmisselector=content" to the end of the URL.

If you were instead to go to:
http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Sites/TEST/fragme...


You would see the object's metadata. That metadata includes a property called cmis:versionLabel, and you've correctly identified that it is not queryable.

Another cmis selector you might be interested in is "versions". If you go to:

http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root/Sites/TEST/fragme...


You will get an array of objects. There's one for every version.

So one way to do what you're asking is to run the query to get the objects back, then ask each object for its versions, picking the instance of the specific version you are interested in.

It's perfectly acceptable to use the raw browser binding like this, but you might find it easier to use a library like OpenCMIS. Then you won't have to dig to figure out what the proper URLs are.

Jeff