cancel
Showing results for 
Search instead for 
Did you mean: 

How to get document tags using REST API?

Arnault_
Confirmed Champ
Confirmed Champ

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

8 REPLIES 8

ssze_
Star Contributor
Star Contributor

Is there a solution to setting and getting tags via the REST API

Arnault_
Confirmed Champ
Confirmed Champ

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();
    }

}

Christian

ssze_
Star Contributor
Star Contributor

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

ssze_
Star Contributor
Star Contributor

Hi Christian,

...

ssze_
Star Contributor
Star Contributor

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.

Arnault_
Confirmed Champ
Confirmed Champ

Hi,

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.