Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 21:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×oauth_resp=$(curl -X POST -u "mykey:mysecret" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials)
curl "https://api.bitbucket.org/2.0/repositories/myworkspace/mytestrepo/deployments_config/environments/{4d857618-d89d-4c4d-92a5-af70e46e4e9f}/variables" \ --request GET \ --header "Content-Type:application/json" \ --header "Authorization: Bearer $oauth_token"
UUID for the environment was got through a different GET so it's correct afaik.
response is
{"error": {"message": "Bad request", "detail": "Unexpected response body", "data": {"key": "unexpected.response.body", "arguments": {}}}}%
What I actually want to do is post deployment environment variables but that doesn't work either.
Status: 404 Headers: {'Server': 'nginx', 'Cache-Control': 'max-age=900', 'Content-Type': 'application/json; charset=utf-8', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Date': 'Sun, 08 Mar 2020 19:30:35 GMT', 'X-Served-By': 'app-1129', 'X-Static-Version': 'a856747ae2e5', 'ETag': '"d8570ff7a4314593e35e9bc69e81400a"', 'X-Render-Time': '0.0081090927124', 'Connection': 'Keep-Alive', 'X-Version': 'a856747ae2e5', 'X-Request-Count': '2694', 'X-Frame-Options': 'SAMEORIGIN', 'X-Cache-Info': 'caching', 'Content-Length': '52'} Error Response: b'{"type": "error", "error": {"message": "workspace"}}
API 2.0 seems to work fine for the more common get/post but fails on the less common requests. I say "less common" because the documentation is rubbish on deploy and repository variables and so I assume that no one wants to automate those things
Ok. I answer myself.
My mistakes were two
So, let's say your UUID is "{127cf9ca-920b-4a1f-a44d-36be6c330316}". So the request should be:
curl -u user:password "https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines_config/variables/\{127cf9ca-920b-4a1f-a44d-36be6c330316\}"
Thanks for your hints.
{
"error": {
"message": "Not found",
"detail": "The value provided is not a valid uuid."
}
}
curl --location --request POST 'https://api.bitbucket.org/2.0/repositories/workspace/repo_slug/deployments_config/environments/{envrionment_uuid}/variables' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic base64_encoded_app_un:pw' \
--data-raw '{
"type": "pipeline_variable",
"uuid": "environment_uuid",
"key": "AWS_DEFAULT_REGION",
"value": "us-east-1",
"secured": false
}'
Thanks for looking.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The other alternative that worked for me was to use the html codes for { and } which are %7B and %7D
deployments_config/environments/%7B{env_uuid}%7D/variables
(this is python so the curly brackets you see are part of the variable subsitution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the info.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Rupert Broad and @mkleint
I am in a very similar situation with pipeline_config/variables
I am able to get all variables with:
curl -u user:password https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines_config/variables/
But if I get the UUID from the response of the first command and try to get the data of a specific variable, it does not work:
curl -u user:password https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines_config/variables/{UUID}
Very probably it is a problem with curly brackets, as @Rupert Broad mentioned. But I don't understand what is the problem exactly.
Could you describe better your solution?
Thank you in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ps: I get the same error message.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In my case I had to escape only the UUID, like:
curl -X DELETE -s -u myusername:${app_password} \
"https://api.bitbucket.org/2.0/repositories/myworkspace/myrepo/pipelines-config/caches/\{4dfb9bec-...-b9cd\}"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
there must be something related to your curl that's causing the problem. I've tried the API with my postman setup and got back a 200 for my repository. It all looks ok to me on the surface though. Maybe some kind of escaping issue in bash?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@mkleintthanks for looking at this - apparently it's the curly brackets that are causing the issue. That and the poor API documentation ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.