Hi all,
I've tried for probably hours to get the below working but I just can't seem to be able to create an environment variable. The API I'm calling is ...
$ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"key": "mytestkey", "value": "value1", "secured": false }' https://api.bitbucket.org/2.0/repositories/<username>/<repo-slug>/deployments_config/environments/{environment UUID in curly brackets}/variables
The error I get is :
{"error": {"message": "Not found", "detail": "The value provided is not a valid uuid."}}
The environment UUID I use in the URL is what is returned from a GET on
https://api.bitbucket.org/2.0/repositories/<username>/<repo-slug>/environments/
Can anyone see what I'm doing wrong pls (I think I'm following the API docs at : https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/deployments_config/environments/%7Benvironment_uuid%7D/variables ). I'm not sure the API docs are strictly correct on that URL above because I don't know how you can include a UUID in the payload when you're creating a variable.
Many thanks for any help / tips...
Hi @curtisa ,
You will need to encode the characters for the curly brackets in order for this to work.
{ should be replaced with %7B and } with %7D
An example call:
curl -X POST -H "Content-Type: application/json" -u username:app-password -d '{"key": "mytestkey", "value": "value1", "secured": false }' https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/deployments_config/environments/{26e47eac-2770-4b69-8f23-92634d03a443}/variables
where 26e47eac-2770-4b69-8f23-92634d03a443 is the UUID of my Pipelines environment.
Could you please give this a try?
Please feel free to let us know if it works or if you need further assistance.
Kind regards,Theodora
Hi!
How did you get the uuid ?
Hi,
By calling
and then picking the uuid value of the environment I want to set the variable for, i.e...
"uuid": "{abcdefg-12345-abcd-1234-abc1234567890}"
Hi Theodora,
Yes that fixed it many thanks.
Kind regards
Alex
Hi Alex,
That's good to hear, thank you for the update and you are very welcome!
It looks like you're new here. Sign in or register to get started.