06-24-2019 07:18 AM
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
06-24-2019 12:13 PM
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.
06-25-2019 02:38 AM
Thanks for quick response Axel.
06-27-2019 02:24 PM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.