Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Quickstart: REST Upload

Docs come with a REST Interface for upload documents. This allows continuous delivery of documents using a continuous integration server such as Bamboo or Jenkins. So, documents can be kept on the latest version in Confluence.

REST URL for uploading a packaged doc (-javadoc.jar / .zip) and CREATE a new item in a specific category:

Code Block
languagebash
Method:    PUT
URL:       /rest/docs/2.0/repository/{CATEGORY_ID}/{DOC_NAME}

REST URL for uploading a packaged doc (-javadoc.jar / .zip) and UPDATE an existing item: Each document is identified by its unique key. The key consists of two alphanumeric strings separated by a dash (cxxxx-dxxxx).

Code Block
Method:    POST
URL:       /rest/docs/2.0/repository/{DOC-KEY}

CURL Example

The following is a command-line sample of how to CREATE a Javadoc "lib-javadoc.jar" in the specific category with the identifier "c1075". The confluence installation is available at "http://confluence.example.org".

Code Block
languagebash
curl -u username:password --upload-file lib-javadoc.jar http://confluence.example.org/rest/docs/2.0/repository/c1075/testDoc

This sample demonstrates how to UPDATE an existing doc using the curl command. The value "c1075-d1082" in the URL is the key of the document to be updated.

Code Block
languagebash
curl -u username:password -X POST --upload-file javadoc.jar http://confluence.example.org/rest/docs/2.0/repository/c1001-d1004 -H "X-Atlassian-Token: no-check"

Watch the CURL-Upload Video: https://youtu.be/iHJRdzhd8HA

Python Script

This is a python sample of how to UPDATE a doc:

Code Block
languagepy
import sys
import base64
import httplib
import urllib

# get params
keyDoc = sys.argv[1]
docFile = sys.argv[2]

# server authentication
auth = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
headers = {"X-Atlassian-Token": "nocheck", "Authorization": "Basic %s" % auth, "Content-Type": "application/json"}

#update doc
conn = httplib.HTTPSConnection("confluence.example.org")
conn.request("POST", "/rest/docs/2.0/repository/" + keyDoc, open(docFile, "rb"), headers)
response = conn.getresponse()
conn.close()

# finished...
print response.status
print "-----"  
print response.reason

Here, the corresponding command-line call for executing the python script above:

Code Block
languagebash
python scripts/docs-upload.py "c1075-d1082" "javadoc.jar"

Endpoints

The following is a list of all supported REST endpoints of the Docs Plugin.

Get Repository Details

Return a JSON object representing the menu structure of the docs repository.

Code Block
Method:    GET
URL:       /rest/docs/2.0/repository/  

Create Doc

Upload and create a new doc archive (.zip / .jar) under the defined category.

Code Block
Method:    PUT
URL:       /rest/docs/2.0/repository/{categroy-id}/{doc-name}

Update Doc

Upload a doc archive (.zip / .jar) and UPDATE the specified (existing) doc.

Code Block
Method:    POST 
URL:       /rest/docs/2.0/repository/{doc-key}

Delete Doc

Delete a specific doc.

Code Block
Method:    DELETE 
URL:       /rest/docs/2.0/repository/{doc-key}

Rename Doc

Rename a doc.

Code Block
Method:    POST 
URL:       /rest/docs/2.0/repository/{doc-key}/{doc-name}

Load Doc Details

Get Details about a specific doc.

Code Block
Method:    GET
URL:       /rest/docs/2.0/repository/{doc-key}

Load Category Details

Get Details about a specific Category.

Code Block
Method:    GET
URL:       /rest/docs/2.0/repository/{category-id}

Create Category

Create a new category (menu item) in the repository.

Code Block
Method:    PUT
URL:       /rest/docs/2.0/repository/{categroy-name}

Link Space Permission

Set a category SpaceKey for permission adjustments. (new in version 2.2)

Code Block
Method:    POST
URL:       /rest/docs/2.0/repository/{categroy-id}/spacekey/{spaceKey}

Delete Category

Delete a category (menu item).

Code Block
Method:    DELETE
URL:       /rest/docs/2.0/repository/{categroy-id}

Export Doc as ZIP Archive

Export doc as ZIP Archive. (new in version 2.5.3)

Code Block
Method:    GET
URL:       /rest/docs/2.0/repository/archive/{doc-key}

Find Category by Name

Find all categories by name. (new in version 2.5.3)

Code Block
Method:    GET
URL:       /rest/docs/2.0/repository/findByName/{name}

Find Doc in a Category by Name

Find all docs in a category by name. (new in version 2.5.3)

Code Block
Method:    GET
URL:       /rest/docs/2.0/repository/{categroy-id}/findByName/{name}

Table of Contents

Table of Contents
minLevel1
maxLevel7
excludeTable*