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

unable to featch the repo enviroment variables through the python

Surendhiran Balaguru September 2, 2024

I am currently encountering an issue when attempting to fetch repository environment variables as part of updating their values.

  1. Creation of Values: I can successfully create environment variables using the provided UUID.

  2. Fetching UUIDs: However, I am unable to retrieve the UUID value via the API GET request. The request returns a 404 error with the following message:

    "There is no API hosted at this URL.\n\nFor information about our APIs, please refer to the documentation at: https://developer.atlassian.com/bitbucket/api/2/reference/"

Since I need to update multiple values in multiple environment values based on env_name in the repository (there are many, so I am aiming for automation), I am facing this challenge.

 

 

USERNAME = 'xxyy'

PASSWORD = 'xxxxyyyyy'

WORKSPACE = 'workspace'

REPO_SLUG = 'repo-name'

url = "https://api.bitbucket.org/2.0/repositories/{WORKSPACE}/{REPO_SLUG}/deployments_config/environments"

# Headers for authentication

headers = {

    'Authorization': f'Bearer {PASSWORD}'
}

# Make the GET request

response = requests.get(url, auth=(USERNAME, PASSWORD), headers=headers)

if response.status_code == 200:

    # Parse the JSON response

    data = response.json()

    # Extract and print the repository names

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

 

 

1 answer

0 votes
Ian Dick
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 2, 2024

Are you trying to use this API?

https://developer.atlassian.com/cloud/bitbucket/rest/api-group-deployments/#api-repositories-workspace-repo-slug-environments-get

If so I think you need to drop the /deployments_config part of the URL, it's just /environments at the end:

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/environments
Surendhiran Balaguru September 4, 2024

This works great thank you :)

 

Suggest an answer

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

Atlassian Community Events