Hello people.
I am trying to create Confluence page from Jira Issue Creation with post function.
I have code which works. my problem is that ,i want to create this page as a child page to an existing Page, which i created earlier.
def issueKey = 'PT-6'
def spaceKey = 'PT'
def result = get("/rest/api/3/issue/${issueKey}")
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status != 200) {
return "Error retrieving issue ${result}"
}
```
def subtitle = "${result.body.key} - ${result.body.fields.summary}"
def pageContent = """<p>Document date:7/25/2019</p>
<ac:structured-macro ac:name='jira' ac:schema-version='1' ac:macro-id='ab120ae6-a585-4b2f-a713-4d23b355dc17'>
<ac:parameter ac:name='server'>System JIRA</ac:parameter>
<ac:parameter ac:name='columns'></ac:parameter>
<ac:parameter ac:name='serverId'>9cd10b67-ca88-369e-937a-42f902e4289b</ac:parameter>
<ac:parameter ac:name='key'>${issueKey}</ac:parameter>
</ac:structured-macro>"""
def parent = createconfluencePage("Initiation1", spaceKey)
createConfluencePage(subtitle, spaceKey, pageContent, parent)
String createConfluencePage(String pageTitle, String spaceKey, String pageContent, String parentPage) {
def params = [
type : "page",
title: pageTitle,
space: [
key: spaceKey
],
body : [
storage: [
value : pageContent.toString(),
representation: "storage"
]
]
]
if (parentPage != null) {
params["ancestors"] = [parentPage].collect { [id: parentPage.toString()] }
}
def pageResult = post('/wiki/rest/api/content')
.header('Content-Type', 'application/json')
.body(params)
.asObject(Map).body
if (pageResult.statusCode) {
logger.error("Failed to create a new page. Confluence responded with error code: {}", pageResult.statusCode)
} else {
logger.info("Successfully created a new space with id: {}", pageResult)
}
pageResult.id
}
parent
```
AS you see i need Page Link or id in
" def parent = createConfluencePage("Initiation1", spaceKey) "
How to get it?