Good morning community!
I'm working on a project related with confluence for the company I work for and I've been trying to code in Python a simple program to download analytic reports exported to excel, I've been searching through the API and found something that seems to be similar to what I need (here), the issue I am having is that using the code that is provided in the page I referenced before something doesn't seem to work, as everytime I run it I get displayed the following message "{"reason":"InsufficientPermissions"}", and that seems to be that I have not autohrized myself, as in the api token site it's does not update the last access. Does anybody know if I'm not using the code correctly? or can anybody show me an example of how I should be coding the authorization? Because I've been researching through the community posts and I've seen that you can create a Confluence object, but that doesn't seem to be useful for me. Below you have an example of the code I'm using.
import requests
import json
url = "https://your-domain.atlassian.net/wiki/rest/api/space/{spaceKey}/label"
headers = {
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
}
response = requests.request(
"GET",
url,
headers=headers
)
Thanks in advance.
Not sure if that is the cause, but you have to use and access token in a specific format. See here for how to make this token: https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/#supplying-basic-auth-headers
It worked, I had to encode the token in base 64 as it said, thanks!!
You'll need to encode your authorization credentials to base64. There are online tools (i.e., https://www.base64encode.net/) that you can use to create your base64 encoded string. For example,
your_email@domain.com:your_user_api_token
base64 encoded iseW91cl9lbWFpbEBkb21haW4uY29tOnlvdXJfdXNlcl9hcGlfdG9rZW4=
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Christian García Welcome to the Community! Just change the code below and see if that works -
"Authorization": "Basic <access_token>"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.