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?

Vivin Raj Jul 24, 2013

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

0 votes
Rambanam Prasad Jul 24, 2013

check the following document to know how to create page using api

http://docs.servicerocket.com/display/ATLASSIAN/API+-+Confluence+-+Creating+and+Modifying+Pages

Nabil Sayegh Dec 16, 2014

The documentation requires a login

bahar pattarkine Sep 19, 2016

is that documentation private 

0 votes
Vivin Raj Jul 24, 2013

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?

0 votes
Philipp Steinwender Jul 25, 2013

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

MartinO Feb 19, 2015

404 Page not found

Philipp Steinwender Feb 19, 2015

I think the link pointed to this page: https://docs.atlassian.com/atlassian-confluence/REST/latest/

0 votes
Vivin Raj Jul 30, 2013

Thank you very much Phillipp

0 votes
Martin Ottesen Sep 20, 2016

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;
    }
}
bahar pattarkine Sep 20, 2016

how does your pom file looks to use 

PageManager 
bahar pattarkine Sep 20, 2016

for using PageManager  how your pom file looks like 

Martin Ottesen Feb 13, 2017

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>
Sandeep Boorla Nov 29, 2017 • edited

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.

0 votes
shashank Sep 14, 2017

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?
Sandeep Boorla Nov 29, 2017 • edited

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 in Opsgenie

Introducing Postmortems for Opsgenie

When incidents happen, it is crucial to diagnose and solve the problem as fast as possible. Equally important to this, teams need a way to reflect on why the incident occurred and how they can improv...

221 views 3 6
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