Example scripts
To homepage
Confluence

Create content template in Confluence Cloud
App in script

ScriptRunner For Confluence
by Adaptavist
Compatibility

Confluence
Language |
groovy
import com.atlassian.confluence.rest.clientv1.model.ContentTemplate
def templateName = "Page test Template"
def templateDescription = "The custom template description"
// Specify the body of the page in storage format - below is some example storage format.
def storageFormat = """<h1>A page created by ScriptRunner</h1>
<p>The first line of my page.</p>
<p>The second line of my page</p>"""
def body = [
templateType: "page",
name: templateName,
description:templateDescription,
body:[
storage:[
value: storageFormat,
representation: "storage"
]
]
]
def response = post('/wiki/rest/api/template')
.header('Content-Type', 'application/json')
.body(body)
.asObject(ContentTemplate)
if (response.status != 200) {
logger.error("Failed to create template.")
} else {
logger.info("Successfully created template: {}", response.body.name)
}
Having an issue with this script?
Report it here