Labels not added to page with labelManager.addLabel

Hi all,

I am currently building a Confluence Addon that creates pages dynamically with a scheduled job. So far everything works fine and the pages are created correctly. However, when trying to add a label with the labelManager, the label is created within the Database, but is not show on the new created page.

The code itself is quite simple:

// here the page will be created
Page createdPage = createNewPage(pageName, source);

// here the label should be created and added to the page
labelManager.addLabel(createdPage, new Label("new Label"));

I also tried

LabelUtil.addLabel("new Label", labelManager, createdPage);	

But that did not change anything. I also received “LabelManager.LABEL_ADDED;” as response when adding a label to the page, but still not showing.

Has anybody an idea what might be wrong here? I am currently using the latest Confluence Server build

Cheers,

Matthias

I don’t know if it’s “wrong”, per se, but isn’t “new Label” actually two labels? (“new” and “Label”). Labels should be all-lower-case without spaces. Try “newlabel” and see if it changes anything.

@MatthiasSchouten I have a similar code and works fine, although I only do this on already existing pages. Can you try with a page that already exists, instead of creating a new one?
Perhaps you have to save the new page afterwards, if you are not doing it already, e.g.:

pageManager.saveContentEntity (createdPage,  DefaultSaveContext.builder ()
                                                                    .suppressAutowatch (true)
                                                                    .suppressEvents (true)
                                                                    .suppressNotifications (true)
                                                                    .build ());

@abianche-boc I have tried this also with existing pages. Did not work :frowning:

I will try to use the saveContentEntity

@SeanMahnken yes you a right, it is here just to indicate a placeholder. I usually would have a lowercase label here