Using the REST api from Bamboo on demand

Lee Myring April 8, 2015

The latest I can find on this is this question and the link in the third answer is dead

https://answers.atlassian.com/questions/236167

This was last updated in 2013 and I wondered if there is a way of triggering Cloud Bamboo build plans via cURL?

 

11 answers

1 accepted

1 vote
Answer accepted
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 8, 2015

Hello Lee,

Please, run the following http://myhost.com:8085/bamboo/rest/api/latest/info [GET]:

# [USERNAME], i.e.: myuser
# [MYCOMPANY], i.e.: mycompany
curl -D- -u [USERNAME] -p -H "Content-Type: application/json" -X GET https://[MYCOMPANY].atlassian.net/builds/rest/api/latest/info

Kind regards,
Rafael P. Sperafico
Atlassian Support

1 vote
Morgan Eason March 21, 2018

Sharing this for others having the same issue. 

AUTHENTICATION_DENIED on the login meant the user needed to fill out the CAPTCHA due to too many failed login attempts. 

I went to the application we were trying to use the API for and logged in. Once successfully answering the CAPTCHA the login then worked though the API.

0 votes
Ankur Verma November 15, 2015

tried this - and it worked.

curl -D- -u admin:<PASSWORD> -H "Content-Type: application/json" -X GET https://<COMPANY>.atlassian.net/builds/rest/api/latest/info

the trick is to use admin as the user and the normal account password. The <COMPANY>.atlassian.net is the url that was setup when you first signed up for bamboo.

0 votes
Lee Myring April 8, 2015

Tried that format already but gave it another go and I still get

HTTP/1.1 401 Unauthorized

 AUTHENTICATION_DENIED

 

rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 8, 2015

Hello Lee, Please, do not add extra parameters to the URL provided (no Authorization:Basic ***, no ?os_authType=basic). Just copy and run the cURL I have provided as it is by only replacing [USERNAME] and [MYCOMPANY]. [USERNAME] cannot be an email address as you have attempted earlier — Kind regards, Rafael P. Sperafico Atlassian Support

Lee Myring April 8, 2015

Ahhhh thanks, I was always under the impression that my username was my email. When I changed it my actual username that I went hunting for in my profile it worked! I was then able to add basic authorisation headers which saved me having to do a two step authentication process....many thanks

0 votes
Lee Myring April 8, 2015

Also tried the following command too

curl -D- -p -H "Content-Type: application/json" -H "Authorization:Basic ***" -X GET "http://mycompany.atlassian.net/builds/rest/api/latest?os_authType=basic"
0 votes
Lee Myring April 8, 2015

So I tried your curl...

curl -D- -u lee.myring@mycompany.com -p -H "Content-Type: application/json" -X GET "https://mycompany.atlassian.net/builds/rest/api/latest?os_authType=basic"

It asked me for my password which I duly entered

Enter host password for user 'lee.myring@mycompany.com':

And I received 

HTTP/1.1 401 Unauthorized
Server: nginx
Date: Wed, 08 Apr 2015 17:24:39 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 1137
Connection: keep-alive
X-Seraph-LoginReason: AUTHENTICATION_DENIED
WWW-Authenticate: OAuth realm="https%3A%2F%2Fmycompany.atlassian.net%2Fbuilds"
&lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/6.0.32 - Error report&lt;/title&gt;&lt;style&gt;&lt;!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--&gt;&lt;/style&gt; &lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 401 - Basic Authentication Failure - Reason : AUTHENTICATION_DENIED&lt;/h1&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Status report&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;Basic Authentication Failure - Reason : AUTHENTICATION_DENIED&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;This request requires HTTP authentication (Basic Authentication Failure - Reason : AUTHENTICATION_DENIED).&lt;/u&gt;&lt;/p&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;h3&gt;Apache Tomcat/6.0.32&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;
0 votes
Lee Myring April 8, 2015

ok...just got your reply...will try your command

0 votes
Lee Myring April 8, 2015

So I tried this...

curl -X GET --user lee.myring@mycompany.com:*** "https://mycompany.atlassian.net/bamboo/rest/api/latest?os_authType=basic"

and received this...

&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;302 Found&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Found&lt;/h1&gt;
&lt;p&gt;The document has moved &lt;a href="https://mycompany.atlassian.net/builds/rest/api/latest?os_authType=basic"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;address&gt;Apache/2.2.3 (CentOS) Server at mycompany.atlassian.net Port 80&lt;/address&gt;
&lt;/body&gt;&lt;/html&gt;

So I then tried this...

curl -X GET --user lee.myring@mycompany.com:*** "https://mycompany.atlassian.net/builds/rest/api/latest?os_authType=basic"

and received this...

&lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/6.0.32 - Error report&lt;/title&gt;&lt;style&gt;&lt;!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--&gt;&lt;/style&gt; &lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 401 - Basic Authentication Failure - Reason : AUTHENTICATION_DENIED&lt;/h1&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Status report&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;Basic Authentication Failure - Reason : AUTHENTICATION_DENIED&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;This request requires HTTP authentication (Basic Authentication Failure - Reason : AUTHENTICATION_DENIED).&lt;/u&gt;&lt;/p&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;h3&gt;Apache Tomcat/6.0.32&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;

So I followed it up with the @ symbol replaced with %40 and got the same message of AUTHENTICATIO_DENIED

curl -X GET --user lee.myring%40mycompany.com:*** "https://mycompany.atlassian.net/builds/rest/api/latest?os_authType=basic"


0 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 8, 2015

Hello Lee

When running Bamboo under HTTPS protocol, please run the cURL command as per following:

# [METHOD], i.e.: GET, POST, PUT
curl -D- -u [USERNAME] -p -H "Content-Type: application/json" -X [METHOD]

Kind regards,
Rafael P. Sperafico
Atlassian Support

0 votes
Lee Myring April 8, 2015

Hi Rafael, 

thanks for the super quick response. 

Whenever I try to run a command I get 301 Moved Permanently codes...for example

curl -X GET --user username:password "http://mycompany.atlassian.net/bamboo/rest/api/latest?os_authType=basic"


I know all the rest api documentation is for non-cloud bamboo...does it work for Atlassian OnDemand 

0 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 8, 2015

Hello Lee,

Thank you for your question.

Please, refer to the following documentation for further information:

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events