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. Based on: http://docs.python-requests.org/en/master/ https://docs.python.org/2.7/library/json.html https://confluence.atlassian.com/confkb/confluence-url-list-317949394.html https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples For someone who found this topic by “search machines”, there is some more detailed how-to – probably can help you: https://www.guru99.com/restful-web-services.html 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 requestsShort Read more…

Atlassian Confluence REST API (Eng)

How to work with REST API Confluence. Rus 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 IShort Read more…

Atlassian Confluence REST API

Как работать с REST API Confluence. Eng  О чем этот топик? Структура API в системе Confluence. Объекты, файлы, статьи, родство и проч. Формирование запроса(адреса) в API Confluence Открытие сессии и удержание её в памяти – ! Формирование заголовков при помощи модуля requests и – json ! Отправка файла, содержания файла, вики-разметки на сервер Confluence – ! Интерпретируем ответы от сервера Что такое Atlassian Confluence вы можете почитать здесь: https://www.atlassian.com/software/confluence https://ru.wikipedia.org/wiki/Confluence Кому нужен этот топик? Тем мученикам, которые хотят автоматизировать процесс написания/отправки документации в разработке. Тем мученикам, которые как и я, по очевидным примерам не могут разобраться в модуле requests касаемо работе с заголовками. Мне самому, чтобы не забыть свой “подвиг” и все его наработки, так как память имеет свойство “стираться”.   В тот момент, когдаShort Read more…

How tired I am of Google way how get API tokens

You must: Create application and take its id and secret. Make a GET request to send secret and id with needed scopes of access. Obtain TEMPORARY access token and refresh token (first lives about 3000 – 5000 sec, the second can probably live infinite) Use this access token to GET something through REST, check if this token is not expires already. 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. 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,Short Read more…

Google Drive API

Thanks to this guy, whose question and gist helps me understand the google api and requests for it to get access for google drive. http://stackoverflow.com/questions/22534959/access-google-drive-api-in-python-whithout-google-api-python-client-installed-a I found everything! If anybody will be confused like me: Get your google drive your_api_key from here: https://console.developers.google.com/apis/credentials?project=[your_project] in section with name “API keys” – or you can generate it by pushing “New Credentials” -> “API key” Also you can get your token with google “quick start” even for python3: https://developers.google.com/drive/v2/web/quickstart/python Your token will be saved on system user’s folder (C:/Users/user/.credentials) or (/root/.credentials) for Linux if you run it under “root”. The token is in “access_token” key value. Then you can generate request, but at first check this: http://docs.python-requests.org/en/master/user/quickstart/#custom-headers And this is working example toShort Read more…

vk execute + args + python + requests

Продолжаю закреплять выученное своим горьким опытом и методом тыка по теме vk execute и python, наконец мои рученьки-загребученьки добрались до последнего оплота и просто приятного и некогда непонятного метода, и также к хранению процедур в приложении! Ура. В прошлом посте я рассказывал как передать строку с vk script сразу таки прям по воздуху, сырую и некрасивую, сегодня мне покорился вариант “хранимые процедуры” который позволяет тело скрипта хранить в приложении вк, а передавать по “воздуху” только необходимые и меняющиеся аргументы: id группы, id поста и так далее. Ближе к делу: каждая переменная, которая будет записываться переданным аргументом должна иметь такой вид: Args.var_name var comments = API.wall.getComments( {“owner_id”:(Args.owner_id), “post_id”:(Args.post_id), “need_likes”:”1″, “offset”:”0″, “count”:”100″, “sort”:”asc”, “preview_length”:”1″, “extended”:”0″, “v”:”5.27″}); var comments_cnt = comments.count; comments = comments.items;Short Read more…