In this topic I’ll show you how to make session to Atlassian Confluence with python requests and keep it in memory.
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):
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):
Get content by id
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.