atlassian-api / atlassian-python-api Goto Github PK
View Code? Open in Web Editor NEWAtlassian Python REST API wrapper
Home Page: https://atlassian-python-api.readthedocs.io
License: Apache License 2.0
Atlassian Python REST API wrapper
Home Page: https://atlassian-python-api.readthedocs.io
License: Apache License 2.0
Hi.
I'm trying to authenticate like this on the public bitbucket site:
username = os.environ['CRONOHUB_BITBUCKET_USERNAME']
password = os.environ['CRONOHUB_BITBUCKET_PASSWORD']
url = os.environ['CRONOHUB_BITBUCKET_URL']
bitbucket = Bitbucket(
url=url,
username=username,
password=password)
data = bitbucket.project_list()
where username is my username, the password is an App password that I generated ( I don't have a password since I created my account via Google Oauth ) and url is https://bitbucket.org
.
All I get back is this:
b''
HTTP Error occurred
Response is: b''
Expecting value: line 1 column 1 (char 0)
Which tells me nothing.
The update_or_create
function logs the URL of the updated or created page. While this might be important information, it is being logged at WARNING
level, which means it is printed out by default.
I do not believe this information should be logged at WARNING
level, or printed out by default, as that assumes how the function is being used; i.e., it's being run from somewhere that the user will always see the output, it's only used on a handful of pages at a time, etc...
this line in Confluence.update_or_create
result = self.create_page(space, parent_id, title, body)
should be
result = self.create_page(space=space, parent_id=parent_id, title=title, body=body)
because
def create_page(self, space, title, body, parent_id = None, type='page')
as it currently is, parent_id get passed in as title, title as body etc.
I am free to submit a PR to fix this right? Working on it.
atlassian-python-api/atlassian/confluence.py
Line 184 in 159fa24
spaceKey
should be SpaceKey
Current method returns no pages.
Atlassian API returns a paged JSON answer.
This shoulde be managed by wrapper too, extending array with all the results.
Hello Guys,
Is this module prepared for the Atlassian's GDPR API changes?
https://blog.developer.atlassian.com/app-opt-in-api-migration/
After uploading *.png file it have 'application/octet-stream' content type. And displayed incorrectly in Confluence Web UI.
I fixed it with replacing (here):
return self.post(path=path, data=data, headers=headers, files={'file': infile})
with
return self.post(path=path, data=data, headers=headers, files={'file': (filename, infile, content_type)})
It will be super nice to have some method to set git tags
Hi ,
I am having problems while doing a confluence search with cql. If the username and password are correct everything is great. However if the username or password are incorrect i get a HTTP error. I want to capture this so it can just display authentication error rather than the full stack out put.
Can you advise where i capture this so that i can handle it as an except. Sorry if this is a little obvious, but i am new to python.
Thanks
Jonathan
Please add support for getting child pages of a given page by its ID or Title.
My use case is that I want to create a load of pages based upon a confluence pages from Jira JQL (one page per Epic), then label each one so I can easily create a Page Properties table.
Could I ask you please remove logging.basicConfig()
in RestClientAPI
it take effect on logger system on import state and broke logging set in caller code.
Hi,
function "confluence.update_page" and "confluence.update_or_create" is overwriting the content.
Is there any way where we append the new content with the existing content in the page?
Hi. I like your python api frontend. One question though. How do you disable SSL certificate checking. Do you have a value that can be set that's passed onto the request module?
Thanks!
Glen Collins
Hi,
Is this library compatible with the Atlassian Cloud?
Please include this info into the documentation too, thanks!
Regards,
Akos
You seem to be demonstrating some usage examples of JIRA and Confluence, however, it doesn't look like there is any mention of Bamboo API however, is Bamboo portion complete?
Hi, which error should I catch with except?
Is there a way to use create a page in Confluence with create_page(), which has Confluence Markdown enabled?
Hi,
I am attempting to use cql to search for keywords throughout Confluence. I define the space key to search and then iterate over the results. Using the following simple search works to some extent:
cql = "space.key= {}".format(space)
However this only produces the 'excerpt' value in the resulting JSON and not the full page. So I am trying to expand the body in each page. Using the following search in the browser against the api returns the full page details as required:
/rest/api/content/search?cql=space.key=S2&expand=space,body.view
However calling 'cql' via the atlassian-python-api gives the following:
cql = "space.key={} +and+expand=space,body.view".format(space)
{'statusCode': 400, 'data': {'authorized': False, 'valid': True, 'allowedInReadOnlyMode': True, 'errors': [], 'successful': False}, 'message': 'Could not parse cql : space.key=X +and+expand=space,body.view', 'reason': 'Bad Request'}
So it appears to be having trouble parsing the request - though the equivalent works in the browser. Is this a bug perhaps or am I missing something simple?
Many thanks
Hello,
It seems like your README file is out of sync with your code. We are now required to provide the parent_id of the page we wish to create, however, even when I provide the page_id of the parent page, the page still doesn't get created..
The current version in PyPI is 0.13.2. Why hasn't this been updated to 0.15.1 to match this repo?
Hi,
I want to get context some page, for example
http://confluence01:8080/pages/viewpage.action?pageId=1123123123
How solve this task?
Hi There.
We have a bitbucket Project with more than 1000 Repositories. When I run the function repo_lists with a limit of 99999 it only shows me 1000 Repositories
data = bitbucket.repo_list(project_key, limit=99999 )
Is there a limitation in your code or in the api?
it would be great if the limitation would be raised and if there were a possiblity to filter the results in the repo_list function like this:
data = bitbucket.repo_list(project_key, filter='MyFilter' )
Thanks
Markus
When I do self.confluence.get( {{ attachment/_links/download }} ) I get error 404 on
https://company.atlassian.net/download/attachments
with base url: https://company.atlassian.net/wiki
Then when I try to fix url by adding 'wiki' in front, I get error 404 on
https://klarrio.atlassian.net/wiki/wiki/download/attachments
While I understand that Basic Auth is quite simple to use at first hand, I think it would be nice (and much more secure) to have the opportunity to use other Authentification Methods offered by the Atlassian APIs, such as OAuth2.
Did you try implementing OAuth2 yet?
There are several syntax errors in the latest update_page method in confluence.py.
The code below resolves these issues this does make parent_id none optional again but I didn't want to change the method signature
def update_page(self, parent_id, page_id, title, body, type='page'):
log.info('Updating {type} "{title}"'.format(title=title, type=type))
if self.is_page_content_is_already_updated(page_id, body):
return self.get_page_by_id(page_id)
else:
version = self.history(page_id)['lastUpdated']['number'] + 1
data = {
'id': page_id,
'type': type,
'title': title,
'body': {'storage': {
'value': body,
'representation': 'storage'}},
'version': {'number': version}
}
if parent_id is not None:
data['ancestors'] = [{'type': 'page', 'id': parent_id}]
return self.put('/rest/api/content/{0}'.format(page_id), data=data)
Is there a method to create branches in BitBucket? I didn't see it, but I may have missed it.
I am using atlassian-python-api==1.12.6
This call
pprint(confluence.get_space('MYSPACE'))
returns
Received: 404 Not Found {'message': 'null for uri: ' 'https://mycompany.atlassian.net/rest/api/space/MYSPACE?expand=description.plain,homepage', 'status-code': 404}
And indeed, the API docs says that the api root is wiki/rest/api and not rest/api.
Overriding the api_root did not change anything:
Confluence(username=user,
password=api_token,
api_root='wiki/rest/api',
url='https://mycompany.atlassian.net'
But the return value of get_space() is the same.
Could you please check / suggest?
Maybe I just want to update another field and because there's loggin on the function using provided summary, I'll have to fetch the previous summary even if I'm not changing anything on it or else this throws an error
Could we make it optional? Say, if there's no summary provided, log the first field being provided on the argument.
If Yes, I would be happy to make that change.
Traceback (most recent call last):
File "con_update.py", line 37, in
parent_id=22028117
File "C:\Python36-32\lib\site-packages\atlassian\confluence.py", line 76, in update_page
'version': {'number': version}})
File "C:\Python36-32\lib\site-packages\atlassian_init_.py", line 57, in put
return self.request('PUT', path=path, data=data, headers=headers).json()
File "C:\Python36-32\lib\site-packages\atlassian_init_.py", line 42, in request
response.raise_for_status()
File "C:\Python36-32\lib\site-packages\requests\models.py", line 851, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error``
from pprint import pprint
from atlassian import Confluence
confluence = Confluence(
url='xxx',
username='xxx',
password='xxx')
status = confluence.update_page(
parent_id=22028117,
page_id=38284221,
title='',
body='<h1 id="WindowsSignatureSet2.4.131.3-2-HandoffinstructionstoOperations">Handoff instructions to Operations</h1>',
)
print(status)
Hi guys, i have been looking over the documentation and can cant quite work out how to search a project in jira for a project.
Any direct you could give would be great.
In updating a page, I am getting the error below. Is there a way to include an increment version in the confluence.update() function?
Update: I am updating the page with MarkUp. Plain text, works fine.
My code is as follows...
This works:
status = confluence.update_page(
parent_id=None,
page_id=123456,
title='Proof of Concept',
body = 'Some text here')
This does not work (although works fine for a create_page):
status = confluence.update_page(
parent_id=None,
page_id=123456,
title='Proof of Concept',
body={'storage': {'value': str(pageBody),'representation': 'wiki'}})
where pageBody is MarkUp
Error:
{'statusCode': 400, 'data': {'authorized': False, 'valid': True, 'allowedInReadOnlyMode': True, 'errors': [], 'successful': False}, 'message': 'Must supply an incremented version when updating Content. No version supplied.', 'reason': 'Bad Request'}
The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.
Using the API I make a call to jira.user_deactivate with the user name via an admin user and I get no errors, but when I log into the site, the user still has full site access. Is this method non-functional?
I'm not able to get user_deactivate
to work. I'm running this against a JIRA server version 7.3.1:
from atlassian import Jira
import sys
import os
jira = Jira(
url='https://jira.example.com',
username=os.environ['JIRA_USERNAME'],
password=os.environ['JIRA_PASSWORD'])
print(sys.argv[1])
jira.user_deactivate(sys.argv[1])
I'm getting back an enormous Java stack trace, wrapped in HTML. The most interesting part of the stack trace seems to be:
java.lang.NullPointerException
at com.atlassian.jira.web.action.admin.user.EditUser.buildNewUser(EditUser.java:86) [classes/:?]
at com.atlassian.jira.web.action.admin.user.EditUser.doValidation(EditUser.java:45) [classes/:?]
This JIRA server has been modified to work with Okta for SAML2 authentication, which involves disabling the jsp.login_jsp
servlet. Is that the cause of the error I'm seeing?
Cześć Matt,
Mam problem po uruchomieniu: jira-project-leaders.py
Jeżeli lider projektu ma login zawierający myślnik to skrypt się nie wykonuje. (np. admini-warszawa)
Wygląda na to że trzeba coś poprawić w jira,py
def project_leaders(self): for project in self.projects(): key = project['key'] project_data = self.project(key) lead = self.user(project_data['lead']['key']) yield { 'project_key': key, 'project_name': project['name'], 'lead_name': lead['displayName'], 'lead_key': lead['key'], 'lead_email': lead['emailAddress']}
z góry dzięki za pomoc
jira.py's get_project_issues_count
def should escape project name. Otherwise one may face issues like this if project key contains reserved JQL words:
ERROR:atlassian:{'errors': {}, 'errorMessages': ["Error in the JQL Query: 'INPUT' is a reserved JQL word. You must surround it in quotation marks to use it in a query. (line 1, character 11)"]}
Thanks @MattAgile for this nice start-up, I am wondering how can I send attachment files to a confluence page. I guess this is not included in your API. Any plans to do so? Thanks!
Hi there,
I tried to play around with this function, but this function always returns None object.
Could you specify how to use this function?
Regards
Hi,
If I use the CQL search to look for a string containing a special character then I get a status code 400.
For example searching for the word 'C#ess' fails with status code 400 and:
'message': 'Could not parse cql'
Searching for the same string via the Confluence UI seems to parse the special character by replacing with %23. For example:
cql=siteSearch+~+"C%23ess"
I've tried escaping the special characters to no avail and also used CQL to search directly for C%23ess - but then I run into the problem of using another special character so it still won't work.
Am I missing something here or is this a bug?
Thanks very much
I'm creating a Confluence page using confluence.update_or_create
function and it shows list index out of range
in output. Seems like the exception occurs when page is not exist and should be created. This error is a bit confusing because page is being created without any problems, so this error doesn't actually indicate something went wrong.
DEBUG:atlassian:curl --silent -X GET -u 'confluence_user':'********' -H 'Content-Type: application/json' -H 'Accept: application/json' 'https://confluence.example.com/rest/api/content/123833032?expand=space'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): confluence.example.com:443
DEBUG:urllib3.connectionpool:https://confluence.example.com:443 "GET /rest/api/content/123833032?expand=space HTTP/1.1" 200 None
DEBUG:atlassian:Received: 200
{'id': '123833032', 'type': 'page', 'status': 'current', 'title': 'KB pages', 'space': {'id': 68452369, 'key': '~confluence_user', 'name': 'User, Confluence', 'type': 'personal', '_expandable': {'metadata': '', 'icon': '', 'description': '', 'homepage': '/rest/api/content/69927984'}, '_links': {'self': 'https://confluence.example.com/rest/api/space/~confluence_user', 'webui': '/spaces/viewspace.action?key=~confluence_user'}}, 'extensions': {'position': 'none'}, '_expandable': {'container': '/rest/api/space/~confluence_user', 'metadata': '', 'operations': '', 'children': '/rest/api/content/123833032/child', 'restrictions': '/rest/api/content/123833032/restriction/byOperation', 'history': '/rest/api/content/123833032/history', 'ancestors': '', 'body': '', 'version': '', 'descendants': '/rest/api/content/123833032/descendant'}, '_links': {'self': 'https://confluence.example.com/rest/api/content/123833032', 'base': 'https://confluence.example.com', 'context': '', 'collection': '/rest/api/content', 'webui': '/display/~confluence_user/KB+pages', 'edit': '/pages/resumedraft.action?draftId=123833032&draftShareId=39e02a1e-4681-4204-a438-b90ec259f650', 'tinyui': '/x/yIthBq'}}
DEBUG:atlassian:curl --silent -X GET -u 'confluence_user':'********' -H 'Content-Type: application/json' -H 'Accept: application/json' 'https://confluence.example.com/rest/api/content'
DEBUG:urllib3.connectionpool:https://confluence.example.com:443 "GET /rest/api/content?spaceKey=~confluence_user&title=example_confluence_page HTTP/1.1" 200 None
DEBUG:atlassian:Received: 200
{'results': [], 'start': 0, 'limit': 25, 'size': 0, '_links': {'base': 'https://confluence.example.com', 'context': '', 'self': 'https://confluence.example.com/rest/api/content?spaceKey=~confluence_user&title=example_confluence_page'}}
ERROR:atlassian.confluence:list index out of range
INFO:atlassian.confluence:Page does not exist because did not find by title search
Hi,
Upload plugin for Jira is not working since creating url function removes trailing spaces but Atlassian's API not responding without trailing space. 🤦♂️
It would be nice to have a method to obtain the body of a given page.
You could then update a page, making modifications to its body.
This method will have as an input the page_id and return the page body content formatted as html.
I will soon submit a PR to fix this issue.
(If I am not mistaken, the current update_or_create()
method replaces the content of the page.)
Kind regards,
Argyris
Because of the change to the behavior of get_page_by_title, page_exists always return true, even if the page doesn't exist.
When logging is turned on, user's login information, including clear text password, is printed.
DEBUG: curl --silent -X GET -u '[email protected]':'Password1' -H 'Content-Type: application/json' -H 'Accept: application/json' 'https://example.atlassian.net/wiki/rest/api/user?username=vt102'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.