Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can you programmatically create a banner for a Confluence space?

Bill Brinkley May 19, 2022

I want to create a space in Confluence programmatically and add a banner to the space at the same time. I do not see that option in the REST API. Am I missing it? We are using Data Center. Thanks

1 answer

0 votes
Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 19, 2022

Hi @Bill Brinkley 
I hope you are well.

I don't think there's an API method to customize the Space layout, such as a header.

However, you might be able to get a similar result by running the same request from the UI through an automation.

Here's an example of creating a Space and then setting the header to a Panel Macro.

 

CONFLUENCE_BASE_URL=http://localhost:27180/c7180
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin
NEW_SPACE_KEY=TESTSPACE
NEW_SPACE_NAME="Test Space"
NEW_SPACE_HEADER_PANEL='{panel:borderStyle=dashed|borderColor=blue|titleBGColor=#00a400|titleColor=white|bgColor=#72bc72}This is a Test Space{panel}'


# Create the Space
curl -v -o /dev/null -X POST -u ${ADMIN_USERNAME}:${ADMIN_PASSWORD} \
${CONFLUENCE_BASE_URL}'/rest/api/space' \
-H 'Content-Type: application/json' \
-d '{"key": "'${NEW_SPACE_KEY}'", "name": "'${NEW_SPACE_NAME}'"}'


# Adjust the Header
curl -v -o /dev/null -X POST -u ${ADMIN_USERNAME}:${ADMIN_PASSWORD} \
${CONFLUENCE_BASE_URL}'/spaces/docustompagecontent.action' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'X-Atlassian-Token: no-check' \
-d 'sidebarText=' \
--data-urlencode headerText="${NEW_SPACE_HEADER_PANEL}" \
-d 'footerText=' \
-d 'key='${NEW_SPACE_KEY} \
-d 'confirm=Save'

This will result on the following Space.

test-space.png

 

Kind regards,
Thiago Masutti

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.13.2
TAGS
AUG Leaders

Atlassian Community Events