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

Updating a pipeline variable using REST API 2.0

Strong January 9, 2020

Hi,

I'm trying to update a pipeline variable using Cloud REST API request:

/2.0/repositories/{workspace}/{repo_slug}/pipelines_config/variables/{variable_uuid}

So my query is

curl -X PUT -u log:pass https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines_config/variables/{variable_uuid} -H 'Content-Type: application/json' -d '{ "key": "%NAME%", "value": "%NEW VALUE%"}'

And the response is

"error": {"message": "Bad request", "detail": "Unexpected response body", "data": {"key": "unexpected.response.body", "arguments": {}}}}

Even when I'm trying to use GET in order to retrieve a repository level variable, I still get the same error

2 answers

0 votes
Fredys Romero August 26, 2020

I was facing the same error and noticed that sending the uuid including the curly brackets in the URL make it work.

Curly brackets must be encoded '{' = %7B  '}' = %7D

Fails: /aaaa-bbbb-cccc-dddd

Fails: /{aaaa-bbbb-cccc-dddd}

Works: /%7Baaaa-bbbb-cccc%7D  

 

curl -X PUT -u log:pass https://api.bitbucket.org/2.0/repositories/my_workspace/repo_slug/pipelines_config/variables/%7Bvariable_uuid%7D  -H 'Content-Type: application/json' -d '{ "value": "%NEW VALUE%"}'

Deleted user November 12, 2020

@Fredys Romero  You, Sir, my hero for today!

This last bit (url-encoding the curly braces) was the missing part for me to make it work. 

Shame on you Atlassian for such a poor documentation which results on such a poor developer experience.

Johan Dewe (PostNord) February 25, 2021

Thanks. I was pulling my hair out for this.

I truly believe this is the worst API I've used, all categories. 

0 votes
Lenin Raj
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 11, 2020
Strong January 14, 2020

Hi @Lenin Raj
Thanks for your reply
Unfortunately it doesn't work and I get the same error

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events