Using the REST api from Bamboo on demand
Asked by Lee Myring:

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?


Answers:
author: rsperafico
body: Hello Lee,

Please, run the following [http://myhost.com:8085/bamboo/rest/api/latest/info](https://docs.atlassian.com/bamboo/REST/5.8.0/#d2e150) \[[GET](https://docs.atlassian.com/bamboo/REST/5.8.0/#d2e151)\]:

```
# [USERNAME], i.e.: myuser# [MYCOMPANY], i.e.: mycompanycurl -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


author: Morgan Eason
body: 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.


author: Ankur Verma
body: 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](https://functionize.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](https://functionize.atlassian.net/builds/rest/api/latest/info) is the url that was setup when you first signed up for bamboo.


author: Lee Myring
body: Tried that format already but gave it another go and I still get

HTTP/1.1 401 Unauthorized

AUTHENTICATION_DENIED

comments: author: rsperafico
body: 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. SperaficoAtlassian Support


author: Lee Myring
body: 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


author: Lee Myring
body: 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"
```


author: Lee Myring
body: 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 UnauthorizedServer: nginxDate: Wed, 08 Apr 2015 17:24:39 GMTContent-Type: text/html;charset=utf-8Content-Length: 1137Connection: keep-aliveX-Seraph-LoginReason: AUTHENTICATION_DENIEDWWW-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;
```


author: Lee Myring
body: ok...just got your reply...will try your command


author: Lee Myring
body: 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"
```

<br />


author: rsperafico
body: Hello Lee

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

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

---

Kind regards,  
Rafael P. Sperafico  
Atlassian Support


author: Lee Myring
body: 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"  

<br />

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


author: rsperafico
body: Hello Lee,

Thank you for your question.

Please, refer to the following documentation for further information:

* [http://myhost.com:8085/bamboo/rest/api/latest/queue/{projectKey}-{buildKey}](https://docs.atlassian.com/bamboo/REST/5.8.0/#d2e653) \[[POST](https://docs.atlassian.com/bamboo/REST/5.8.0/#d2e656)\]

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


Tags: cloud