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: "
it's always returning a 404 error.
The same request, GET, is working as expected returning the list of variables.
Any clue?
Thank you
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Carlos,
No worries! Glad to know that this has helped you out :)
Cheers!
- Ben (Bitbucket Cloud Support)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.