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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bamboo REST API: Always fails with insufficient permissions Edited

Hello,

I am attempting to use the Bamboo REST API from within Bamboo to check on the state of a previous job. However, I'm unable to get this to work.

According to the documentation for the version we are using (6.9.1), I can use the /result API - https://docs.atlassian.com/atlassian-bamboo/REST/6.9.1/#d2e5392

/result/{projectKey}-{buildKey}/{buildNumber : ([0-9]+)|(latest)}

Using the script below, I'm sending a GET request to a URL similar to (where the build number changes each time) -

https://my.bamboo.url/rest/api/latest/result/LP-RBIT2-RIT/8?buildstate&os_authType=basic

However, this is failing with a 401 error. The user that is authorising the REST call has admin privileges for the plan in question, so I'm not sure why this would be. I've check also to ensure that the user is active (with 0 of 3 failed captcha attempts).

You do not have sufficient read permissions

I've reviewed the documentation for using the Bamboo REST APIs, and I can see any mention of further Bamboo configuration being required to enable users to use the REST API. I have also attempted the REST call in a browser, and while I was asked to log in, the browser then receives no response at all (the network tab on F12 is empty).

My script

$bambooUrl = "https://my.bamboo.url"

### Get the state of the job that just ran the tests by using the Bamboo REST API.
$jobStateUserPassPair = "$env:bamboo_apiUsername:$env:bamboo_apiPassword"
$jobStateEncodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($jobStateUserPassPair))
$jobStateBasicAuthHeader = @{ "Authorization" = ("Basic {0}" -f $jobStateEncodedCreds) }
$jobStateUri = "{0}/rest/api/latest/result/{1}/{2}?os_authType=basic" -f $bambooUrl, $env:bamboo_buildKey, $env:bamboo_buildNumber
$jobState = Invoke-RestMethod -Method Get -Uri $jobStateUri

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

674 views 1 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you