add group to developer role on project using python jira

gagan m s November 16, 2018

Hello ,

i need to add an user-group developer role of a project.

can some one get me the code to do this using JIRA module on python using basic auth?

thanks

2 answers

2 accepted

0 votes
Answer accepted
gagan m s November 21, 2018

i finally got it working.

import requests
import json
import Projects
jiraSession = requests.Session()

username = username
password = 'password'
baseURL = 'URL'
try :

jiraSession.post(baseURL+'/rest/auth/1/session',auth=(username, password))
create()
except :
print("Please check connection/ Login Details")
def create():

for i in Projects.users :
for j in Projects.project :
body = json.dumps({
"user" : [
i
]
})
print(i)
response = jiraSession.request(
"POST",
baseURL+'/rest/api/2/project/'+j+'/role/10001',
data=body,
headers={'content-type': 'application/json; charset=UTF-8'}
)

print(response.status_code)


Projects is a py file which contains ID of Projects and names of Users as list.
0 votes
Answer accepted
Edwin Kyalangalilwa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2018

Hi @gagan m s,

Check the code on this link

https://gist.github.com/andrewhancox/5814197

I've used this to clone roles from one project to another.

Make edits where necessary. 

Suggest an answer

Log in or Sign up to answer