Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Status 401 – Unauthorized, trying to get information using Python API

Hello guys.

 

I want to access Confluence (Cloud) using Python.

These are the steps I'm following:

  • Installed the Python API using pip.
  • Created my personal access token in Confluence.
  • from atlassian import Confluence
  • Created the Python script like this:

 

confluence = Confluence(
url='https://xxxxx.xxxx.net',
username='<my_user>',
password='<my_token>',
verify_ssl=False,
cloud=True
)


def main_process():
nRet = 0
cInp = ''

os.system('clear')

try:
cPage = confluence.page_exists('DBM', 'General', type=None)

print(cPage)

except Exception as e:
logging.error(e)

 

And the error log shows this:

DEBUG :06/13/2023 05:39:05 curl --silent -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' 'https://xxxxx.xxx.net/rest/api/content?spaceKey=DBM&title=General'
DEBUG :06/13/2023 05:39:05 Starting new HTTPS connection (1): xxxxx.xxx.net:443
DEBUG :06/13/2023 05:39:09 https://xxxxx.xxx.net:443 "GET /rest/api/content?spaceKey=DBM&title=General HTTP/1.1" 401 751
DEBUG :06/13/2023 05:39:09 HTTP: GET rest/api/content -> 401
DEBUG :06/13/2023 05:39:09 HTTP: Response text -> <!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Basic Authentication Failure - Reason : AUTHENTICATED_FAILED</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Apache Tomcat/9.0.71</h3></body></html>
ERROR :06/13/2023 05:39:09 Expecting value: line 1 column 1 (char 0)
ERROR :06/13/2023 05:39:09 401 Client Error: for url: https://xxxxx.xxx.net/rest/api/content?spaceKey=DBM&title=General

It looks like even with the PTA I still need something else or there is a kind of restriction that I do not understand.

Any help will be much appreciated.

 

Regards

Javier

 

1 answer

Hello.

Forgot to add my installation ...

  • Windows-11
  • WSL2 with Ubuntu 22.
  • Using Ubuntu for this process (from WSL2).

Regards

Javier

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events