Access Confluence Java API (AbstractPage) from Rest Endpoint in a Plugin

Hello everyone. Looking for help.
I have a rest endpoint (javax.ws.rs) in my plugin and tag in my atlassian-plugin.xml. Now in this scenario I want to access the AbstractPage to edit the title.

So a hit at this route: /api/MyRestApi/UpdateTitle/87993 would update the title of the page, using the Confluence Java API.

What is the right way of accessing Confluence Java API from a rest endpoint in a plugin?

Thanks in advance

Hi @JohnReese ,

Are searching for the Java API to help you with this (assuming 87993 is the content ID)? If so you might want to try:

  1. PageManager#getAbstractPage(long contentId) which returns an AbstractPage, or
  2. ContentService#find which returns ContentService.ContentFinder that you can use to locate the Content (which can be a page, blogpost, etc.)

For both approaches, I believe you can edit the title.

Cheers,
Ian

Hello @iragudo thank you!

So i should be able to access it like Get reference to a component

I’ve been trying to call PageManager from my rest service with the Spring Scanner but after setting everything up my plugin somehow breaks and i get the following error

Unresolved requirements: osgi.extender; (&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))]

So, to access the Confluence Java API, i should use the spring scanner right?

Thanks in advance

I believe so, @JohnReese . This is the document I double-checked now and it is aligned with the one you shared.

If autowire does not work for you, have you tried retrieving the component explicitly via ContainerManager#getComponent?

For this error, check this thread, they have discussed this similar problem; might lead you to a solution.

1 Like