Forums

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

Atlassian API Token doesn't work in python script but it works in curl

Petar Dimovski
October 27, 2021

Hello Everyone, 

I created an access token in the atlassian web application and it works when I use curl like this:

curl --user "petar.dimovski@etxcapital.com:TOKEN https://etxcapital.atlassian.net/wiki/rest/api/content&type=page

but when I ping the api from a python script I get the following response:

{"message":"Current user not permitted to use Confluence","statusCode":403}

What should I do in order to make it work like curl does?

Here's the python script:

import os
import requests
from requests.auth import HTTPBasicAuth

confluence_api_url ="https://etxcapital.atlassian.net/wiki/rest/api"

def get_auth_details():
return HTTPBasicAuth(os.getenv("username"), os.getenv('token'))


def get_pages(label=None):
params = {
'type':'page',
# 'start':0,
# 'limit':500
}
if label:
params["label"] = label

resp = requests.get(f"{confluence_api_url}/content/search.json",
auth=get_auth_details(),
params=params)

return resp.json()

 

2 answers

1 accepted

0 votes
Answer accepted
James Malgieri
Contributor
October 16, 2019

We resolved this by discovering this is happening because the first two characters match the first two characters of the SYLK file format which is ID.

To fix this, open the file in Notepad and modify ID to be anything else. The easiest way is to add another character. Save and close Notepad. Then it should open in Excel correctly.

https://en.wikipedia.org/wiki/SYmbolic_LinK_(SYLK)

0 votes
Angélica Luz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 10, 2019

Hi James,

Thank you for reaching out to Atlassian Community!

The CSV type should work with Excel or Google Sheets.

Can you please open the file directly on Excel menu instead of clicking on the file to open?

If possible, send us a screenshot of the error that you see when trying to open the file.

Regards,
Angélica

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events