Reading confluence page.

Poreddy Shiva kumar September 30, 2018

My project uses Atlassian Confluence 6.8.3 and What I am looking for is to read a confluence page with the URL provided, I am trying to build desktop utility which will read confluence content and does the necessary changes in S3 storage. is it possible to read the confluence content with just URL of the page? Please do let me know your thoughts.

I am trying to achieve this using java.

Thanks in advance, I am looking forward to the best solution.

Shiva.

 

1 answer

0 votes
Burak Kocak September 30, 2018

Hi, you can read confluence page with the URL. It will be in HTML format so you need to use HTML tags for finding content. You need to integration user to read pages and this user needs  view permission to get the content.

Poreddy Shiva kumar September 30, 2018

@Burak Kocak Thanks for responding. Can you give any code snippet reference that can help me out?

Poreddy Shiva kumar September 30, 2018

@Burak Kocak The examples over here use the url something like this https://hostname/rest/api/content/id but i have plain url like this 

https://hostname/display/spacename/pagename. I would like to read content from this url.

 

Thanks,

Shiva.

Burak Kocak October 1, 2018

So you can split the URL  its easy to split like

String url = "https://hostname/display/spacename/pagename";
String[] url1 = url.split("https://hostname/display/");
String[] url2 = url1.split("/"); String spKey = url2[0]; //spacekey
String pName = url2[1] ; //pagename

and get the pagename and use rest below ( there is url class in java but use have to split it again). It will return a json, and you can get the page id in it . Then you can use it in

https://hostname/confluence/rest/api/content?title=pagename

now we have page id and

https://hostname/rest/api/content/pageid?expand=body.storage

Returned json will have the content of the page.

You will get lots of problems with this way, because of the spaces and other characters as will harder to work while spliting.

It's better to ask pageid from the user. When the page name changed pageid still same thus it will have a consistency. On the other hand if your user use ASCII char in the name, page URL turn to https://hostname/confluence/pages/viewpage.action?pageId=xxxxxxxx way.

Poreddy Shiva kumar October 1, 2018

@Burak Kocak Thank you.

KamalSingh July 21, 2021

Did this work for you Poreddy. Can you share the code snippet

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events