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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

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.

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

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.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

Community showcase
Published in Training & Certification

Atlassian University Live: Content Management with Confluence

  Atlassian University Live webinars provide you and your teams with the chance to strengthen your Atlassian product skills, and learn directly from Atlassian experts. Explore how to enhance...

55 views 0 2
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you