Atlassian Confluence REST API Making request and keep the session (Eng)

In this topic I’ll show you how to make session to Atlassian Confluence with python requests and keep it in memory.

Atlassian Confluence

Based on:

For someone who found this topic by “search machines”, there is some more detailed how-to – probably can help you:

Python requests module:

At first you should know and understand how requests works, basically.

Check how your confluence works:

Next – you should know the point, where is your Confluence server make authorisation, in my situation it lies here (this is looks cozy, but this is our company’s way. In your situation it can be simpler, as documented in links above):

https://docs.YOURCOMPANYMAME.com/docs/dashboard.action?os_username=configipedia_service_account&os_password=PASSWORD

Then you compose a request like:

This will execute and save the session in memory, so you will not need to authorise each next request.

REST URL composing:

Then you compose the needed URL like it shown here: http://trianglesis.org.ua/atlassian-confluence-rest-api-logic-structure-eng

This will be useful to create this (in KB):

Create content
POST /rest/api/content
Get content
GET /rest/api/content
Update
PUT /rest/api/content/{contentId}
Get content by id
GET /rest/api/content/{id}
Delete
DELETE /rest/api/content/{id}

Session execute:

When you have all needed arguments and space id and parent-child pages of Atlassian Confluence, you can simply add them as like it shown in example above and execute:

In this example you pick up the session stored in memory and just send any needed URL request, then json decode the answer and shows the result. You can do it as many times as you need, the session is open and ready to get and post.

Sometimes its better, than send credentials each time when you GET\POST something.

This example will show all spaces for current user in Atlassian Confluence, then show all pages on it, and all child items with theirs id, title, web link etc.

 

trianglesis

About trianglesis

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