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
If your URL is like http://path.to.your.confluence/display/YOURSPACE/Yourpage?yourparameter=yourvalue, you can access the parameter like this:
## @noparams
$req.getParameter("yourparameter")
In this example the output of the macro would be "yourvalue".
Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.