Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,845
Community Members
 
Community Events
168
Community Groups

Can we create a Confluence Page from a template via REST API?

I'm trying to use the "Send web request" option in JIRA's Project Automation to generate a Confluence Page via REST API

I'm able to use the following code but I don't know how to force Confluence to use an existing template or a global template like "Design Review" when creating the new page.

 

{
"title": "ABCD",
"type": "page",
"space": { "key": "ABC" },
"status": "current",
"body": {"storage": {"value": "Sample Text", "representation": "storage"}}
}

1 answer

You can do this with an undocumented rest api. 

 

First create a new page using the content api as a type of draft:

POST https://company.atlassian.net/wiki/rest/api/content

```

{
    "type""page",
    "status" : "draft",
    "title""test6",
   ...

```

Use the id retreived from this page to update the draft from a template:

PUT https://company.atlassian.net/wiki/rest/api/content/content_id/instance

```

{

{"content":{"id":"content_id","type":"page","title":"employee 1","status":"draft","space":{"key":"HR"},"version":{"number":1},"ancestors":[{"id":"content_id"}]},"contentBlueprintSpec":{"contentTemplateId":"template_id","context":{"employee_name":"a","employee_type":"a"}}}

}

```

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events