Python API error

nannan666
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!
May 23, 2023

Hi Sir 

I want to use python get my page by API ,but i have met an error:

https://github.com/atlassian-api/atlassian-python-api/tree/master/examples/confluence

my page addr:

https://nannan666.atlassian.net/wiki/spaces/CHARTGPT/pages/98517/Oscillation+Detection+Spec

Code:

# coding=utf-8
from atlassian import Confluence

confluence = Confluence(url="https://nannan666.atlassian.net/wiki", username="nannan666", password="xxxx")

# If you know Space and Title
content1 = confluence.get_page_by_title(space="CHARTGPT", title="page title")

print(content1)

# If you know page_id of the page
content2 = confluence.get_page_by_id(page_id=98517)

print(content2)



log:
urn complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://nannan666.atlassian.net/wiki/rest/api/content?type=page&start=0&limit=1&spaceKey=CHARTGPT&title=page+title


1 answer

0 votes
Graham Twine
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2023

Hello @nannan666 ,

 

Have you tried to access the URL from a third party application like Postman or Insomnia first?

 

This is a good place to start so you can confirm you are setting up the call correctly.

Consider request headers as well.

I am not familiar with the library you are using but try and get this working with the Python requests library or the http.client libraries first.

 

Also try and call yourself in the first instance.

/confluence/rest/api/user/current

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events