Atlassian Confluence REST API Logic structure (Eng)

Read this article after you know how to make REST API request to Atlassian Confluence!

atlassian_con

This topic will show you some part of internal scheme of Confluence API and hierarchy.

Based on:

So, looking on the Confluence docs all this scheme looks like well-structured logical system, but it has some difficulties, just as for me.

Before you POST of GET something will be better if you make a probing GET request to see the whole structure in your organisation.

In this example you will get those arguments:

 

# Confluence stats

space_page = This is the page of your Confluence account. Check if was created, sometimes new account have no space.
space_root_page = This is the home page, where you can add widgets, history and etc. Add there a widget with history of all pages created, then you will see when something was posted successfully.
space_id = this is ID of space, not the page on it, just the account’s space.
space_key = ‘~configipedia_service_account’ – this is a name of your service account, this option can show you the space in request like:  https://docs.bmc.com/docs/rest/api/space/~configipediaautomation
space_name = ‘DocBot+space’ – just a space name.
child_page_1 = this is a previously created child page, attached to account space. Just for test purposes. I recommend you to create them to see how it works.
child_page_2 = see above.
confPedia_root = here all you request sentences will starts. confPedia_root/rest/api/…
confPediaUser = your automation user.

# api keys

# Usage example: “confPedia_root+conf_content+space_id” – request to get space homepage content
api = ‘/rest/api/’
conf_space = ‘/rest/api/space/’
conf_content = ‘/rest/api/content/’
conf_children = ‘/child/page/’

After you make this recognition, you should collect all needed arguments: accounts, page ids, space ids – and then you can just compose any path where you want to post topic or file. Make sure that service account have rights to post anywhere else except its own space!

You should know where is space of currently automated account lies:

Here GET and answer examples:

GET THE SPACE:

https://docs.YOURCOMPANYMAME.com/docs/rest/api/space/~configipedia_service_account

GET SPACE CONTENT HOME PAGE:

https://docs.YOURCOMPANYMAME.com/docs/rest/api/content/625685389

Code


GET HOME PAGE CHILD ITEMS CONTENT

https://docs.YOURCOMPANYMAME.com/docs/rest/api/content/625685397

Code


GET CHILD ITEMS FROM PARENT:

https://docs.YOURCOMPANYMAME.com/docs/rest/api/content/625685397/child/page

Code


trianglesis

About trianglesis

Александр Брюндтзвельт - гений, филантроп, 100 гривен в кармане. Этот блог - "сток" моих мыслей и заметок. Достаточно одного взгляда на него, чтобы понять, что такой же бардак творится у меня в голове. Если вам этот бардак интересен - милости прошу.
Bookmark the permalink.