Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to read content of confluence page?

zaharovvv_suek_ru
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2018

I am able to get Conflunce link at Jira issue, but cannot read the content of Confluence page:

def issue = ComponentAccessor.getIssueManager().getIssueObject("GR-5")
log.info('Start')
def rlm = ComponentAccessor.getComponent(RemoteIssueLinkManager)
def links = rlm.getRemoteIssueLinksForIssue(issue)
def onlyConfluenceLinks = links.findAll {
if(it.applicationType == RemoteIssueLink.APPLICATION_TYPE_CONFLUENCE){
log.info(it.applicationType) // Output: com.atlassian.confluence
log.info(it.getSummary()) // Output:
log.info(it.getTitle()) // Output: Page
log.info(it.getUrl()) // Output: https://confluence.com/pages/viewpage.action?pageId=6652581
log.info(it.getSummary()) // Output:
}
}

My Conflunce page looks like that:

List of issues at Confluence page.png

I need to get all LO  issues at this page.
How can I get content of Confluence page?

1 answer

0 votes
MoroSystems Support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2018

Hi,

you have now RemoteIssueLink (documentation). There is no Confluence page content stored in this class.

But you can extract pageId from url property of RemoteIssueLink and get Confluence page content via REST call:

https://confluence.com/rest/api/content/6652581?expand=body.storage

This REST call returns JSON with page content. There should be elements with these tags

<ac:parameter ac:name=\"key\">ISSUE-KEY</ac:parameter>

 in JSON. You shoul be able to get these issues and filter as you need.

 

Regard

Josef Pavelec

zaharovvv_suek_ru
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2018 edited

Hey,  @MoroSystems SupportJosef Pavelec! Thank you for your reply! Could you post some code? 

I've tried the following code:

def curl = "/usr/bin/curl -u admin:admin https://confluence.oop.ru/rest/api/content/6652581?expand=body.storage"
def output = curl.execute().text

But I see the following error:


java.io.IOException: Cannot run program "/usr/bin/curl": CreateProcess error=2, The system cannot find the file specified
at Script6083$_run_closure1.doCall(Script6083.groovy:41)
at Script6083.run(Script6083.groovy:36)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
... 2 more

 

Is it necessary to have ScriptRunner for Confluence to make REST confluence endpoint?

I have ScriptRunner just for Jira.

 

 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events