Endpoint Documentation

HTTP REST API

The REST API documentation describes the usage of the Download Feature to download configs directly from Confluence in your automated provisioning scripts with e.g. curl or wget. All Endpoints can only be accessed by an authenticated Confluence User that has the Page View Permission of the page the codebox is embedded in. Authentication can be done via Basic Auth.

Download the codeblock or raw template

The Endpoint let's you download a specific codeblock as plain text.

GET /plugins/servlet/advanced-codeblock-macro-downloadcode

Request Parameter

pagepropertykey
string

A code to identify the actual codeblock of the codebox. It is the BASE64 encoded version of the section name. Use cmF3 to download the raw template.
Example: dGVzdHN5c3RlbSAx

macroid
int

An unique ID generated by Confluence for the macro.
Example: 1213344

pageid
int

The ID of the Confluence Page the macro is embedded in.
Example: 234324

os_authType
string

Optional. Set this to 'basic' if you want to authenticate via Basic Auth.
Example: basic

asciionly
boolean

Optional. Set this to 'true' if you want to have all non-ASCII chars removed from the response body. This will retain ASCII and [öäüß].
Example: true

Request Example

$
curl https://my.confluence/plugins/servlet/advanced-codeblock-macro-downloadcode \
-G -u admin:admin \
-d pagepropertykey=cmF3 \
-d macroid=95b26f2e-4768-4e66-952e-37a8b56bcac1 \
-d pageid=1703938 \
-d os_authType=basic

Response Codes

200
OK

Download possible Response Body will contain the codeblock as plain text.

401
Unauthorized

Unauthorized Not logged in to Confluence. (Please keep in mind that you will need to use a captcha once your authentication attemps fail to often)

403
Forbidden

Forbidden You do not have the view page permission right on the Confluence Page in which the macro is embedded.

500
Internal error

Internal error Wrong URL-parameters, Confluence page does not exist any more or any other error. Confluence logs the exeption to the logfile.

Response Body

Encoding

UTF-8

Content-Type

text/plain

Response Body Example

<VirtualHost *:80>
  DocumentRoot /var/www/server1
  ServerName www.server1.com
</VirtualHost>

Download xml list

The Endpoint lists all download links for one specific codebox as XML.

GET /plugins/servlet/advanced-codeblock-macro-downloadlist

Request Parameter

macroid
int

An unique ID generated by Confluence for the macro.
Example: 1213344

pageid
int

The ID of the Confluence Page the macro is embedded in.
Example: 234324

os_authType
string

Optional. Set this to 'basic' if you want to authenticate via Basic Auth.
Example: basic

asciionly
boolean

Optional. Set this to 'true' if you want to have all non-ASCII chars removed from the response body. This will retain ASCII and [öäüß].
Example: true

Request Example

$
curl https://my.confluence/plugins/servlet/advanced-codeblock-macro-downloadlist \
-G -u admin:admin \
-d macroid=b77502b0-1dc4-4227-8c11-b03d9f581507 \
-d pageid=360457 \
-d os_authType=basic

Response Codes

200
OK

Download possible Response Body will contain the downloadlist as XML.

<advancedCodeblockMacro>
  <!-- See full example below -->
</advancedCodeblockMacro>

401
Unauthorized

Unauthorized Not logged in to Confluence. (Please keep in mind that you will need to use a captcha once your authentication attemps fail to often)

<advancedCodeblockMacro>
  <error>401 UNAUTHORIZED</error>
  <message>no logged in user found</message>
</advancedCodeblockMacro>

403
Forbidden

Forbidden You do not have the view page permission right on the Confluence Page in which the macro is embedded.

<advancedCodeblockMacro>
  <error>403 FORBIDDEN</error>
  <message>no read permission on page with id 1234</message>
</advancedCodeblockMacro>

500
Internal error

Internal error Wrong URL-parameters, Confluence page does not exist any more or any other error. Confluence logs the exeption to the logfile.

<advancedCodeblockMacro>
  <error>500 ERROR</error>
  <message>Did you provide valid URL-Parameters?</message>
</advancedCodeblockMacro>

Response Body

Encoding

UTF-8

Content-Type

application/xml

Response Body Example

  1. The first codeblock is for [testsystem 1]

  2. The second codeblock is for [testsystem 2]

  3. The third codeblock is for [raw]

<advancedCodeblockMacro>
 <page>
   <pageId>360457</pageId>
   <pageName>Testpage</pageName>
   <spaceKey>TEST</spaceKey>
   <macroId>b77502b0-1dc4-4227-8c11-b03d9f581507</macroId>
 </page>
 <codeBlocks>
  <codeBlock> 
   <key>dGVzdHN5c3RlbSAx</key>
   <name>testsystem 1</name>
   <download>http://localhost:8090/plugins/servlet/advanced-codeblock-macro-downloadcode?pagepropertykey=dGVzdHN5c3RlbSAx&amp;pageid=360457&amp;macroid=b77502b0-1dc4-4227-8c11-b03d9f581507</download>
  </codeBlock>
  <codeBlock> 
   <key>dGVzdHN5c3RlbSAy</key>
   <name>testsystem 2</name>
   <download>http://localhost:8090/plugins/servlet/advanced-codeblock-macro-downloadcode?pagepropertykey=dGVzdHN5c3RlbSAy&amp;pageid=360457&amp;macroid=b77502b0-1dc4-4227-8c11-b03d9f581507</download>
  </codeBlock>
  <codeBlock> 
   <key>cmF3</key>
   <name>raw</name>
   <download>http://localhost:8090/plugins/servlet/advanced-codeblock-macro-downloadcode?pagepropertykey=cmF3&amp;pageid=360457&amp;macroid=b77502b0-1dc4-4227-8c11-b03d9f581507</download>
  </codeBlock>
 </codeBlocks>
</advancedCodeblockMacro>