As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Hi,
I'd like to get (or set!) a tag to a document using the REST API.
How can this be done?
Thanks for any advice
Christian
Is there a solution to setting and getting tags via the REST API
Hi
After all, since no operation exists, I have developed a new operation SetDocumentTag callable from the APIREST:
@Operation(id=SetDocumentTag.ID, category=Constants.CAT_DOCUMENT, label="SetDocumentTag", description="") public class SetDocumentTag { public static final String ID = "SetDocumentTag"; private static final Log log = LogFactory.getLog(SetDocumentTag.class); @Context protected CoreSession session; @Param(name = "label", required = true) protected String label; @Param(name = "username", required = true) protected String username; @OperationMethod public void run(DocumentModel input) throws Exception { TagService service = Framework.getLocalService(TagService.class); String docId = input.getId(); log.error("SetDocumentTag> docId=" + docId + " tag=" + label + " username=" + username); service.tag(session, docId, label, username); session.save(); } }
Thanks for the operation for setting tags. My only problem is that I do not get the relations via API with the calls outlines above. Do I need a special API call to retrieve tags. Is there some special X-NXDocumentProperties set. If I use the asterisk tags are not included in the response.
Hi Christian,
The strange thing is that there are Operations for "Tag", "Untag" and "Remove all tags" from a document available but there seems to be no means for getting the tags set on a document via the API. I will have a look at the TagService now.