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

Cannot add deployment config environment variable

Carlos Patón July 14, 2022

I am not able to create variables for the environments we have in different repositories.

The request we are doing is like the following:

curl --location --request POST 'https://api.bitbucket.org/2.0/repositories/:workspace/:repo_slug/deployments_config/environments/:environment_uuid/variables' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Basic thisisatest3czo5RGZWR1d5cjZDbYTU0Nw==' \
--data-raw '{
"key": "name",
"value": "test"
}'

environment_uuid is encoded with the '{' and '}', like this: "

%7B12fa2ce1-5c4c-4f92-b250-9c557e6096ef%7D"

it's always returning a 404 error.

The same request, GET, is working as expected returning the list of variables.

Any clue?

 

Thank you

 

1 answer

1 accepted

0 votes
Answer accepted
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 17, 2022

G'day Carlos!

Welcome to the Bitbucket Cloud Community! :) 

Your API request is almost correct, however, you need to also have the "secured" property present as false or true ie:

"key": "name",
"value": "test",
"secured": false 

When running the command from my end successfully, my request looked like this (I have used --user instead of header as you can just copy and paste your App Password directly without encoding it):

curl --request POST \
--url https://api.bitbucket.org/2.0/repositories/{workspaceID}/{reposlug}/deployments_config/environments/%7B{Environment_UUID}%7D/variables \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--user Username:AppPassword \
--data '{
"key": "hello",
"value": "test",
"secured": true
}'

 Try this and let me know how it goes.

Cheers!

- Ben (Bitbucket Cloud Support)

Carlos Patón July 19, 2022

Thank you very much for the help. It now works :)

Like Ben likes this
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 19, 2022

Hey Carlos,

No worries! Glad to know that this has helped you out :)

Cheers!

- Ben (Bitbucket Cloud Support)

Suggest an answer

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

Atlassian Community Events