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

using powershell to Grant permission to bamboo project to User using REST API

krishnateja October 26, 2022

Hi Team , 

We are trying to  implement to grant project permission to the user using powershell , and we are stuck in how to pass this values  "[ \"READ\", \"CREATE\",\"ADMINISTRATION\"]" to a rest api 

this below is the powershell syntax

$jParams = @{
Uri = (<bambooURL>, rest/api/latest/permissions/project/ -join "/") + "<ProjectName>" + "/users/" + "userID"
Method = 'PUT'
Headers = $jHeaders
}

How to pass this values "[ \"READ\", \"CREATE\",\"ADMINISTRATION\"]" to below command

try {
$bambooProjectAdminAddDataResponse = Invoke-RestMethod @jParams -ErrorAction Stop
}

 

Please assist us if anyone has suggestion how to achieve this 

1 answer

1 accepted

0 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 26, 2022

Hello @krishnateja ,

Please try the following:

$userID = '<username>'
$password = '<password>'
$credPair = "$($userID):$($password)"
$ProjectName = "<ProjectKey>"
$BambooURL = "https://bamboo.mydomain.net"

$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credPair))

$Body = @( "READ", "CREATE", "ADMINISTRATION" )

$JsonBody = $Body | ConvertTo-Json

$Params = @{
Method = "Put"
  Headers = @{ 'Authorization' = "Basic $encodedCredentials" }
  Uri = -join($BambooURL + "/rest/api/latest/permissions/project/" + $ProjectName + "/users/" + $userID)
  Body = $JsonBody
  ContentType = "application/json"
}

Invoke-RestMethod @Params

You can find more information about Bamboo REST API on this page:

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

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

krishnateja October 28, 2022

Thanks Eduardo Alvarenga ,

The solution helped us a lot. .!

Like Eduardo Alvarenga likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events