cancel
Showing results for 
Search instead for 
Did you mean: 

REST API endpoint to add aspects to a file

onkovic
Confirmed Champ
Confirmed Champ

I am trying to create an ADF component which allows users to add new aspects to a document, similar to the Manage Aspects button in Share. However, I do not find a corresponding method in the Angular class AlfrescoApi, so I guess I will have to write my own service which first fetches all available aspects for a file via REST API and later adds the chosen aspects to that file.

What is the recommended REST API endpoint for these operations?

1 ACCEPTED ANSWER

janv
Employee
Employee

Hi,

Please also note that aspects will be auto-added when you set one or more properties within the aspect.

However, if you want to have fine-grained control, for example to remove an aspect (with all it's properties) or to add a so-called "marker" aspect (hat has no properties) then you should be able to use:

Alfresco Content Services REST API Explorer 

Note: if you want to add or remove aspects, then you must use GET /nodes/{nodeId} first to get the complete set of aspectNames.

I haven't had a chance to test JavaScript API (or check code) to see if you can do update "aspectNames" (via the "updateNode" API) ... please let us know if this works ? 

Regards,

Jan

View answer in original post

2 REPLIES 2

janv
Employee
Employee

Hi,

Please also note that aspects will be auto-added when you set one or more properties within the aspect.

However, if you want to have fine-grained control, for example to remove an aspect (with all it's properties) or to add a so-called "marker" aspect (hat has no properties) then you should be able to use:

Alfresco Content Services REST API Explorer 

Note: if you want to add or remove aspects, then you must use GET /nodes/{nodeId} first to get the complete set of aspectNames.

I haven't had a chance to test JavaScript API (or check code) to see if you can do update "aspectNames" (via the "updateNode" API) ... please let us know if this works ? 

Regards,

Jan

onkovic
Confirmed Champ
Confirmed Champ

Hi Jan, this is some great information. Thank you! I will try both approaches. 

I have a follow-up question though. To enable users to pick new aspects, I will have to display all available aspects for a file in a list. Where can I retrieve the information which aspects are available for a given file?