Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using Confluence Python API

Deleted user
September 5, 2021

I'm trying to get started with the python API for our cloud instance and am having some issues. I can't seem to find a simple example anywhere so thought I would lay this out with some details and hope for some insight.

API is here: https://atlassian-python-api.readthedocs.io/

I have a token created from: https://id.atlassian.com/manage-profile/security/api-tokens

My token has a token-label and a token-string.

First question: what's the right way to instantiate a Confluence object.  Should the site URL include the "/wiki" to represent confluence or not? Do I use the token label and string, or do I use my email and token string?

 

confluence = Confluence(
url='https://my-site.atlassian.net/wiki', # with or without /wiki?
username="my-email", # is this my email or my token label?
password="token-string",
cloud=True)

Second question: what is the right way to reference a space and a page.  I have a space named "Company Information" and a first-level page called "Company Tools" and I just want to see if the page exists. The following code always returns false, however, so something is amiss.  Interestingly, I get false returned her if I pass my token label as "username" into the above constructor; and an ApiPermissionError if I pass in my email.

 

# What are the right parameters for this function?
if
confluence.page_exists("Company Information", "Company Tools"):
print("page exists")
else:
print("page not found"

Third question: my final attempt was to get the set of spaces in Confluence.  I am an administrator so you'd think I would have access.  With the token label, I get an error here.  With my email, I get an array, but my print statement prints some labels that doesn't make any sense to me.  Is there a way to get more details specs on these commands?

# Just trying to print out all the spaces available to me
spaces
= confluence.get_all_spaces(start=0, limit=500, expand=None)
for s in spaces:
print(s

If there is a good reference for such questions, I would greatly appreciate it.  The documentation seems rather lax (or I'm just not finding it).

Thanks,

Erik

2 answers

1 accepted

0 votes
Answer accepted
LP3-SecurIT
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 13, 2013

I got the issue worked out. Turns out there were a number of issues I was having that were part of this problem. Ultimately I ended up reinstalling everything and making sure I met all of the requirements. I did reinstall MySQL and it looks like everything is working. I believe the issue was the fact I was using an EC2 instance in AWS. Very configurable so there were some things I was missing that were assumed to be installed with Red Hat. Lesson learned!

0 votes
Rodrigo Girardi Adami
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 8, 2013

Hi there!

That's very strange. Are both MySQL and Confluence in the same server or they are in distant networks?

Also, I'm not sure if you are setting a datasource or by jdbc connection. Can you try both so we can rule this out?

And last but not least, which is the database engine? You sholud run Innodb instead of MyISAM.

If everything fails, I recommend to install another MySQL database and test in this one. Maybe the current is not working correctly.

I hope this helps!

Rodrigo

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events