It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to create page using JAVA API?

I have just started using the Confluence JAVA API. I wanted to know how do I create a page using the API if I have a space. Where do I supply the URL of the space?

Thanks!

6 answers

The documentation requires a login

is that documentation private 

Thank you rambanam. But how do I connect to my wiki space to add page. My comapany has a wiki space for employees. What I am trying to do is I want to connect to the empoyee space and push out text to create pages. But I cannot find how to connect to the space. Do I use SOAP?

If you do not develop a plugin, but want to handle this from outside confluence, see: https://developer.atlassian.com/display/CONFDEV/Confluence+Remote+API+Reference

404 Page not found

Thank you very much Phillipp

I ended up creating this method that looked something like this for creating pages....

 

import com.atlassian.confluence.pages.Page;
import com.atlassian.confluence.pages.PageManager;
import com.atlassian.spring.container.ContainerManager;

class MyPageManager {

	public static  Page createChildPage(Page parentPage, String pageTitel){
		PageManager pageManager = (PageManager) ContainerManager.getComponent("pageManager");
        
        Page child = new Page();
        child.setTitle(pageTitel);
        child.setSpace(parentPage.getSpace());
        child.setParentPage(parentPage);
        child.setBodyAsString(content);
        child.setVersion(1);
        child.setCreator(parentPage.getCreator());
        pageManager.saveContentEntity(child, null);
        
        return child;
    }
}

how does your pom file looks to use 

PageManager 

for using PageManager  how your pom file looks like 

If I remember correctly it is located confluence "core" package

 

<dependencies>
	<dependency>
		<groupId>com.atlassian.confluence</groupId>
		<artifactId>confluence</artifactId>
		<version>${confluence.version}</version>
		<scope>provided</scope>
	</dependency>
	...
</dependencies>
...
<properties>
	<confluence.version>5.9.4</confluence.version>
	...
</properties>

Hi Martin, in your code, to create a new Page, you are providing parent page reference as shown in below code lines.

child.setSpace(parentPage.getSpace());
child.setParentPage(parentPage);

I am having the parent page ID. How can I hold the reference of that confluence page as you did for parentPage. Please help me with the code lines and if possible provide some explanation.

Thanks.

Hi Martin Ottesen

i m trying to add confluence child page by using your code

but unable to import the packages nor i am able to find jar file for these packages

 

import com.atlassian.confluence.pages.Page;
import com.atlassian.confluence.pages.PageManager;
import com.atlassian.spring.container.ContainerManager;


could help me to find out which jar file these packages reside?

Hi Shashank, below are the jars you are looking for.

atlassian-spring-2.0.0.jar
confluence-5.9.1-OD-2015.42.1-0002.jar

You can download them from Maven Repository.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Thursday in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

82 views 0 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you