Forums

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

Permission error while trying to list environment variables

Francesco Camussoni November 5, 2024

Hello! I've created a access token with full permission as you can see bellow:

WhatsApp Image 2024-11-05 at 18.06.23.jpeg

 

I'm trying to list Environment variables with the code example of 

https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-deployments-config-environments-environment-uuid-variables-get where I see that I supposedly have the right scopes but have this error:

WhatsApp Image 2024-11-05 at 18.08.07.jpeg

 

Just in case I'm writing the code bellow. The env_uuid was gotten with list environment

# This code sample uses the 'requests' library:

# http://docs.python-requests.org

import requests

import json

workspace = 'gvcorppy'

repo_slug = 'mlendpoint-template'

url = f"https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/deployments_config/environments/{dev_env_uuid}/variables"

headers = {

"Accept": "application/json",

f"Authorization": "Bearer {access_token}"

}

response = requests.request(

"GET",

url,

headers=headers

)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

The access key is correctly configured because I used it in the same way to list the environments

1 answer

1 vote
Jim Knepley - ReleaseTEAM
Atlassian Partner
November 5, 2024

Welcome to the community, @Francesco Camussoni 

Looking at your screenshot, I think you mean to do something more like:

headers = {
"Accept": "application/json",
"Authorization": f"Bearer {access_token}"
}

 

You're treating the hash key as an f-string, but I'm sure you mean that to be the hash value instead.

Francesco Camussoni November 5, 2024

of course a stupid mistake hahah

 

Thank you very much!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events