0

I want to retrieve the content details with API from Alfresco.

From alfresco document I got the following rest url. But I don't know how to get all the content id's from alfresco.

GET alfresco/api/-default-/public/cmis/versions/1.1/atom/content?id={content_id}

It would be grateful if someone explains me.

Anand Rajagopal
  • 1,593
  • 6
  • 24
  • 40
  • Why not just use CMIS all the way? That makes it easy to both list and download (amongst other things) – Gagravarr Feb 24 '15 at 09:55
  • @Gagravarr Thanks for your response, Yes you are right but I did not know all the content id's in a certain folder. In this case how to use CIMS. – Anand Rajagopal Feb 24 '15 at 10:03
  • If you're using CMIS, you don't need to know the content IDs directly, just list a folder and you'll get back document objects, and from those you'll get the content if you want. See [cmis.alfresco.com](http://www.alfresco.com/cmis) for a bit of an intro – Gagravarr Feb 24 '15 at 10:05
  • @Gagravarr thanks, Can you give me a sample API to get the document objects? – Anand Rajagopal Feb 24 '15 at 10:10
  • Depends on what CMIS library you use. [This is the folder listing example for Apache Chemistry](http://chemistry.apache.org/java/examples/example-list-folder.html), if you're using Java – Gagravarr Feb 24 '15 at 10:27
  • No, I am not using java. I just want to get the content details with rest API. – Anand Rajagopal Feb 24 '15 at 10:30
  • There are clients for a wide variety of languages, which handle all the authentication, calling rest APIs etc for you. Just pick a CMIS client for your language and use that! – Gagravarr Feb 24 '15 at 10:37
  • I just want to get all the content details with rest API. Here I have mentioned below sample API GET /alfresco/service/api/metadata?nodeRef=workspace://SpacesStore/c58f4bc2-82d6-477f-94d1-79cffc150c33 in this call I get one document details only. But I need all document Id's with rest API. – Anand Rajagopal Feb 24 '15 at 10:42
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/71588/discussion-between-anand-and-gagravarr). – Anand Rajagopal Feb 24 '15 at 14:04

4 Answers4

2

Each node (node = document or folder) with alfresco has a "NodeRef" property. That's the unique id to use.

You can obtain the NodeRef in many different ways:

  • When searching for objects in a tree, you get back an array with objects as result (including NodeRef properties)
  • When creating an object with the API, the return is an object reference
  • By using the web admin GUI, you can look at the details of a file or folder and see the different properties for that file/folder. NodeRef should be one of the properties listed in the GUI.

Once you know the NodeRef you can access your content with the url like this (example)

/alfresco/api/-default-/public/cmis/versions/1.1/atom/content?id=824ba7cd-dcee-4908-8917-7b6ac0611c97

The returned object should be the node content.

henrik
  • 1,558
  • 3
  • 14
  • 29
0

you can use nodeservice and searchservice to retrieve all node's id in alfresco.you can find usefull method in below links.

http://dev.alfresco.com/resource/docs/java/org/alfresco/service/cmr/repository/NodeService.html

If you are using rest api than you may need to create your custom webscript(alfresco provides rest api using webscript) in alfresco to retrieve all node from alfresco document repository and than using that response you can call above.

Krutik Jayswal
  • 3,165
  • 1
  • 15
  • 38
0

You can take reference of this Recursively get all content file names under a folder in Alfresco 5.0 (by WebScripts)

Just change getChildren.get.json.ftl to

{
    "totalItems": "${totalItems}",
    "nodes":
    [<#list results as node>
        {
            "id" : "${node.id}"
        }<#if (node_index + 1 < results?size)>,</#if>
     </#list>
    ]
}

You will get content id's of all document of specific folder.

Community
  • 1
  • 1
Naman
  • 2,205
  • 2
  • 19
  • 32
  • Thanks for your response. Is that any possible to get all content files using rest API without WebScript? – Anand Rajagopal Feb 24 '15 at 05:44
  • You can use getDescendants Rest Api call to get all folders/documents. Ref:- https://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Retrieve_tree_of_descendants_.28getDescendants.29 – Naman Feb 24 '15 at 05:53
  • Use this to execute: localhost:8080/alfresco/service/api/node/{noderef of folder}/descendants?filter=document&depth=-1 – Naman Feb 24 '15 at 06:29
  • Here I have mentioned below sample API GET /alfresco/service/api/metadata?nodeRef=workspace://SpacesStore/c58f4bc2-82d6-477‌​f-94d1-79cffc150c33 in this call I get one document details only. But I need all document Id's with rest API – Anand Rajagopal Feb 24 '15 at 13:38
  • Yes using this you can get particular folder or document details. To get all document use query mentioned in above comment and search for UUID. You need to pass noderef of folder from which you want aLL documents. – Naman Feb 24 '15 at 14:28
  • can you give me a sample rest API? – Anand Rajagopal Feb 24 '15 at 14:32
  • localhost:8080/alfresco/service/api/node/workspace/SpacesStore/c58f4bc2-82d6-477f-94d1-79cffc150c33/descendants?filter=document&depth=-1 Hit this URL from your browser and search for UUID you will get your output OR if you want only UUID in output than you have to go for Webscript – Naman Mar 13 '15 at 06:42