Get a template in storage format via Confluence REST API

Bastian Stehmann
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 11, 2019

Hi there,

I already managed to get a page in storage format via REST API from Confluence.

Is there also a way to do this for a template.

I want to get the template in storage format to do some modifications (add some data) and then create a page from that template and store that page also via REST API back to confluence.

Thanks

Bastian

2 answers

1 accepted

1 vote
Answer accepted
Tobias Anstett _K15t_
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.
January 11, 2019

Hi @Bastian Stehmann,

You won't find any documentation on this as no public API exists. However there is some experimental API which can be used on your own risk (may break in future versions of Confluence).

I was testing these commands with Confluence 6.14-m77 but the API is there since 5.10. To explore the experimental API's you should install Atlassian's REST API Browser app in Confluence.

This is an example on 'how to get the storage format for a template'. All other steps required for your use case could use public API again.


GET http://localhost:8090/rest/experimental/template/page?spaceKey=BC&expand=body

BS was the spaceKey of the space my template is stored. In the call the body element was expanded as this contains the storage format - see response below.

{
"results": [
{
"templateId": "2752514",
"name": "FOOO",
"description": "",
"space": {
"id": 2555905,
"key": "BC",
"name": "BLANK CONFLUENCE",
"type": "global",
"_links": {
"webui": "/display/BC",
"self": "http://localhost:8090/rest/api/space/BC"
},
"_expandable": {
"metadata": "",
"icon": "",
"description": "",
"homepage": "/rest/api/content/2523138"
}
},
"labels": [],
"templateType": "page",
"body": {
"storage": {
"value": "<at:declarations /><p>FOOOO</p>",
"representation": "storage"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/template/2752514"
}
}
],
"start": 0,
"limit": 25,
"size": 1,
"_links": {
"self": "http://localhost:8090/rest/experimental/template/page?spaceKey=BC&expand=body",
"base": "http://localhost:8090",
"context": ""
}
}

Have fun coding :)

Best, Tobias

Bastian Stehmann
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 11, 2019

Hi Tobias,

thank you very much, that's great.

Best,

Bastian

0 votes
Nermin Skenderovic
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 13, 2024

"I already managed to get a page in storage format via REST API from Confluence."

 

How do you get a page in storage format via the Confluence API?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events