Sample rest url to retrieve content from alfresco

aaviss picture aaviss · Nov 27, 2012 · Viewed 19.2k times · Source

I want to retrieve content of sample.html inside catalog folder in alfresco using restful.

From alfresco document i got the following rest url to retrieve content of a document. But i dont know exactly what is property, stor_type, store_id,id and attach.

GET /alfresco/service/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}

It would be grateful if someone explains me the above rest url properties and provide me a example.

Answer

DNA picture DNA · Nov 27, 2012

The CMIS Web Scripts Reference and the Repository RESTful API Reference give a little more information (but no examples).

  • property is the property of the node to follow in order to obtain the content - this will default to cm:content so can generally be omitted
  • store_type will normally be "workspace" for live application data - see this forum discussion on store types etc
  • store_id will be "SpacesStore" for normal files - see this forum discussion on other stores
  • id is the unique identifier for the node (within a given store), e.g. 986b162e-0867-4a7b-9f4f-0e3837cdc97b
  • attach - if true, force download of content as attachment (defaults to false) - I think this is to trigger "Save as..." in a browser rather than directly streaming the content?

Example GET URL (untested - and of course you'd need to use a valid host, port and id)

http://my.example.com:8080/alfresco/service/api/node/content/workspace/SpacesStore/986b162e-0867-4a7b-9f4f-0e3837cdc97b

Together, the store_type, store_id and id form a NodeRef which uniquely identifies a node, e.g.

workspace://SpacesStore/f1a5e908-80cb-4c6e-b919-cc80fe53b835

There are a couple of examples (though not of this exact API call) on Jeff Potts' tutorial on Curl and web scripts.

If you want to download a file by name and path (without already knowing the node ID) then you will need to use another API, as the one you are using requires you to know the node ID.

This page mentions a direct download URL that accepts a path and filename, e.g.

/alfresco/download/direct?path=/Company%20Home/My%20Home%20Space/myimage.jpg

Depending on access controls, you may need to add the login ticket parameter to this URL, e.g. &alf_ticket=1234567890, where 1234567890 is the security ticket provided by the login URL.


Note: although I refer to the CMIS Web Scripts Reference above, see also this posting and Jira ticket that state that CMIS web script URLs are deprecated, i.e. ( /alfresco/service/cmis and /alfresco/cmis)