Add REST API endpoint for generating space exports in PDF format

XMLWordPrintable

    • 3
    • 8

      Currently we have  REST API functionality for creating space exports only by using XML format. We need to have Rest API to create space/site exports by using PDF format.

      Workaround

      1. The Confluence CLI provides such functionality, but it is a paid third-party add-on. The above functionality would be important to automate migration/backup tasks for administrators.
      2. Although deprecated, you may still use the RPC-API to export the entire Space - see the examples below.

      Export a Space to PDF.

      USRNAME=admin
      USRPWD=password
      CONFBASEURL=http://127.0.0.1:8090/confluence
      SPACE_KEY=SPACEKEY
      
      curl -s \
          --user $USRNAME:$USRPWD \
          -H "Content-Type: application/json" \
          -H "Accept: application/json" \
          -X POST \
          -d '{ "jsonrpc" : "2.0", "method" : "exportSpace", "params" : ["'${SPACE_KEY}'"], "id": 7 }' \
          ${CONFBASEURL}'/rpc/json-rpc/pdfexport?os_authType=basic'
      

      We can use XMLRPC client in Confluence v10 as JSON RPC is deprecated.

      import xmlrpc.client
      server = xmlrpc.client.ServerProxy('http://localhost:8080/confluence/rpc/xmlrpc')
      token = server.confluence2.login('id', 'pass')
      pdf_data = server.pdfexport.exportSpace(token, 'SPACEKEY')
      print(pdf_data)
      

      Space import

      For possible workarounds on importing spaces, please also check this KB article: Confluence Space Import Via Scripting Tools

            Assignee:
            Unassigned
            Reporter:
            Sushree Shailaja Satapathy
            Votes:
            31 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated: