Get node fields using REST API

cancel
Showing results for 
Search instead for 
Did you mean: 
djole87
Member II

Get node fields using REST API

Hi Everyone,

I'm using Alfresco 5.2 Community edition. And I'm trying to do some calls using REST API.
I'm following api-explorer and so far I didn't have any problems... till now.

I would like to use REST API to get all available node fields, but cannot find a way to do this.
Is there a way to get all fields/metadata of any node object?
So I don't need fields of the specific node,I need all possible fields that can be set on any node.

Best regards,
Djordje

3 Replies
afaust
Master

Re: Get node fields using REST API

The Public ReST API does not provide any operation to retrieve dictionary information. This means there is no way to retrieve all properties that "can" be set on a specific node - you basically have to know them from your specific constellation of (custom) meta models. In the legacy ReST API there are operations to retrieve class / property definitions from which you can build a view of "settable" properties, but that operation is marked for "internal" use, e.g. to support Alfresco Share, and is not meant for consumption by general clients.

djole87
Member II

Re: Get node fields using REST API

Thanks for quick response Axel.

abhinavmishra14
Advanced

Re: Get node fields using REST API

No its not an option by default. However its pretty easy to create a Java backed webscript and use DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService) to extract the information you want. 

Dictionary service has methods to return aspects, types and their properties. 

final Map<QName, PropertyDefinition> propertiesFrmType = dictionaryService.getType(DemoContentModel.WhitePaper.TYPE).getProperties();

final Map<QName, PropertyDefinition> propertiesFrmAspect = dictionaryService.getType(DemoContentModel.Webable.ASPECT).getProperties();

Iterate the above map and prepare the response in XML, JSON etc. as you like. 

You can also get details of each property by getting the property definition. 

final QName propertyID = DemoContentModel.Publishable.Properties.ID;

final PropertyDefinition propDef = dictionaryService.getProperty(propertyID); // By passing the QName of a property 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)