I'm receiving 401 when I try run a build plan via API
Asked by Rafael Costa:

401 = Unauthorized.

Where/How I set the autorization to user's call?

I'm trying call <http://myhost.com:8085/rest/api/latest/queue/{projectKey}-{buildKey>} \[POST\]


Answers:
author: Eduardo Alvarenga
body: Hello [@Rafael Costa](/t5/user/viewprofilepage/user-id/4615974)

Thank you for using **Atlassian Community**!

Can you share the full response from the API request?

We also advise you to check the following documentation, which contains some examples that can be useful for you:

* <https://developer.atlassian.com/server/bamboo/rest/api-group-api/#api-api-latest-queue-projectkey-buildkey-post>

Sincerely,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**

comments: author: Rafael Costa
body: [@Eduardo Alvarenga](/t5/user/viewprofilepage/user-id/4365410) the response is:

*HTTP Status 401 -- Unauthorized*

*The request has not been applied because it lacks valid authentication credentials for the target resource.*


author: Eduardo Alvarenga
body: Hello [@Rafael Costa](/t5/user/viewprofilepage/user-id/4615974)

It appears the user provided on the REST API request has no permission to run that build in Bamboo. Can you queue the same build on the UI using that same user?

Please share the API request command you are using to initiate the build.

Bamboo may also give you some clue about the reason it is being rejected. Please check **\<bamboo-home\>/logs/atlassian-bamboo.log** or **\<bamboo-home\>/logs/atlassian-bamboo-access.log**.

Regards,

Eduardo Alvarenga  
Atlassian Support APAC  
**--please don't forget to Accept the answer if the reply is helpful--**


author: Rafael Costa
body: I'm trying create a webhook from Bitbucket to Bamboo. Actually I do it with same user from Jira to Bamboo without problems. But from Bitbucket to Bamboo I'm receiving this error.

![err1.png](https://community.atlassian.com/t5/image/serverpage/image-id/222105i385A4C0EEA8BD2EB/image-size/large?v=v2&px=999 "err1.png")

My main question is: How do I set an webhook from Bitbucket's repository to call a Bamboo plan when a pull request when a Pull Request is approved?


author: Eduardo Alvarenga
body: Hello [@Rafael Costa](/t5/user/viewprofilepage/user-id/4615974)

The Bamboo REST API will only accept Basic authorization or a Personal Access Token. It will not work with OAuth.

We advise you to use the recommended notification method via native integration. When using Application Link integration, Bitbucket will automatically notify Bamboo when any repository changes. You need to have an [Application link](https://support.atlassian.com/jira-cloud-administration/docs/use-applinks-to-link-to-atlassian-products/) between Bamboo and Bitbucket set, and the repository type in Bamboo needs to be either Bitbucket Server or Bitbucket Cloud (available on Bamboo 9).

On Bamboo, your Plan must have an enabled "Bitbucket Repository Trigger". Then once the repository changes, Bamboo will be notified and will initiate a change detection task on the repository and in case of changes, trigger a build.

Here's some documentation on how to integrate Bamboo and Bitbucket:

* [Integrating Bamboo with Bitbucket Server](https://confluence.atlassian.com/bamboo/integrating-bamboo-with-bitbucket-server-779302772.html)

If you wish to use a traditional "Git" repository (not Bitbucket type) in Bamboo you can use either:

* A [Remote trigger via a Post-receive hook](https://confluence.atlassian.com/bamkb/git-repository-remote-trigger-859500786.html) in Bitbucket
* A Webhook - [Triggering a Bamboo build from Bitbucket Cloud using Webhooks](https://confluence.atlassian.com/bamboo0801/triggering-a-bamboo-build-from-bitbucket-cloud-using-webhooks-1101928665.html) -- That's not the URL you are using. *These instructions are designed for Bitbucket Cloud, and also work on Bitbucket Server*

Best regards,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**


author: Rafael Costa
body: Thanks [@Eduardo Alvarenga](/t5/user/viewprofilepage/user-id/4365410) , I did it and worked!!!


Tags: api

build