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

Rest Api failed with "You must enter a valid variable name" when send json data

sunil jaiswal September 19, 2023

I am using bamboo 8.2.5 and when I made the the post request to 

/plan/{projectKey}-{buildKey}/variables it failed with an error saying "

You must enter a valid variable name" When I googled I found this https://jira.atlassian.com/browse/BAM-21787 It indicates that it's a bug but just want to check if we have any alternate way to add variables to the newly created branch plan.
Can anyone share some other method for this.

1 answer

1 vote
Khushboo Gupta
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 19, 2024

Hello @sunil jaiswal 

It seems like you're trying to programmatically add variables to a new branch plan in Bamboo. Unfortunately, as you've discovered, there is a known bug (BAM-21787) in the REST API that prevents this from working as expected.

Please try the workaround given in the BAM

Workaround

Use the following format:

/plan/{projectKey}-{buildKey}/variables?name=foo&value=bar

POST
$ curl -H "Content-Type: application/x-www-form-urlencoded" -u admin:admin -X POST "https://bamboo.mydomain.net/rest/api/latest/plan/ABC-DFG/variables?name=foo&value=var"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><variable name="foo" value="var"/>
GET
$ curl -u admin:admin -X GET "https://bamboo.mydomain.net/rest/api/latest/plan/ABC-DFG/variables" [{"name":"foo","value":"var"}

 

Let me know if this helps!

Regards,

Khushboo Gupta

*please don't forget to Accept the answer if your query was answered**

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events