Just my blog

Blog about everything, mostly about tech stuff I made. Here is the list of stuff I'm using at my blog. Feel free to ask me about implementations.

Soft I recommend
Py lib I recommend

I'm using these libraries so you can ask me about them.

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:

import json
import requests

confluence_auth_url = 'https://docs.YOURCOMPANYMAME.com/docs/dashboard.action?os_username=configipedia_service_account&os_password=PASSWORD'
session = requests.session()

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

REST URL composing:

Then …


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 = '625685389'
space_root_page = '625685397'
space_id = '624689178'
space_key = '~configipedia_service_account'
space_name = 'DocBot+space'
child_page_1 = '625685424'
child_page_2 = '625685428'
confPedia_root = 'https://docs.YOURCOMPANYMAME.com'
confPediaUser = '~configipedia_service_account'

# 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/'


# Confluence stats …


Atlassian Confluence REST API (Eng)

How to work with REST API Confluence.

Rus [caption id="attachment_2385" align="aligncenter" width="609"]Atlassian Confluence REST API Atlassian Confluence REST API[/caption]

What is this topic about?

  • API structure in Atlassian Confluence.
  • Objects, files, relations etc.
  • How to compose API request in Atlassian Confluence?
  • How to open session and hold it on - !
  • Making headers with requests and - json !
  • Send a file or file content with wiki markup on Confluence - !
  • Interpret server answers.
  • What is the difference between "representation":"storage" and "markup" in Atlassian Confluence?
    • Macro and markup

About "Atlassian Confluence" you can read here.

  • https://www.atlassian.com/software/confluence
  • https://wikipedia.org/wiki/Confluence

Who need this?

For those, who wants to automate documentation stage of DEV. For those, who wants to understand how does python requests working? For my own - to not forger this lesson. When I started to make this bot - I know nothing, just like a John Snow, I also …


Atlassian Confluence REST API

Как работать с REST API Confluence.

Eng Atlassian_Python О чем этот топик?

  • Структура API в системе Confluence.
  • Объекты, файлы, статьи, родство и проч.
  • Формирование запроса(адреса) в API Confluence
  • Открытие сессии и удержание её в памяти - !
  • Формирование заголовков при помощи модуля requests и - json !
  • Отправка файла, содержания файла, вики-разметки на сервер Confluence - !
  • Интерпретируем ответы от сервера

Что такое Atlassian Confluence вы можете почитать здесь:

  • https://www.atlassian.com/software/confluence
  • https://ru.wikipedia.org/wiki/Confluence

Кому нужен этот топик?

Тем мученикам, которые хотят автоматизировать процесс написания/отправки документации в разработке. Тем мученикам, которые как и я, по очевидным примерам не могут разобраться в модуле requests касаемо работе с заголовками. Мне самому, чтобы не забыть свой "подвиг" и все его наработки, так как память имеет свойство "стираться".   В тот момент, когда я решил заняться автоматизацией процесса документации в своей компании я не знал, насколько кастрирована наша Confluence и насколько убогий, окажется в принципе сам её API, как долго придется возиться с тем, чтобы …


I'm WORDPRESS I've made REST look at me!

Thanks, for UTF-8 support!

title=\"\u041d\u0430\u0436\u043c\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438 \u043d\u0430 Pinterest\">


How tired I am of Google way how get API tokens

Google APIYou must:

  1. Create application and take its id and secret.
  2. Make a GET request to send secret and id with needed scopes of access.
  3. Obtain TEMPORARY access token and refresh token (first lives about 3000 - 5000 sec, the second can probably live infinite)
  4. Use this access token to GET something through REST, check if this token is not expires already.
  5. You want to GET something ELSE? First check if your token is not expired, then if expired - use refresh token to get NEW TEMPORARY token.
  6. Do something else.

Nice turn google! You are the best of masters of creating shitcode. Before starting real work on google API and my own project with Google Drive I'll learn pythons "requests" perfectly, first! Thanks google you will make me smarter! Example of shitcode which is needed to get the token first, then check if it is not expired and then request NEW …


Ну здравствуй, Google Drive API

Ну здравствуй, Google API! Всего каких-от пару месяцев назад, я бы никуй не понял, в этом эльфийском коде. А теперь посмотрите на меня! Я все равно почти ничего не понимаю, но уже умею им пользоваться! Google API В самом начале, на пути создания няшного приложения под гугл-диск.