The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Update project roles with Python?

Kate Secor
April 4, 2025

I am using the jira-python library, and I'm trying to figure out how to update project roles with it.

I see there's an add_user() method for the Role class, but I can't figure out how to instantiate a new Role associated with a specific project role in my instance.

I'm a python newbie, so maybe I'm just missing something obvious?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Ana Vitória Selista
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 Champions.
April 5, 2025

Hi Kate,

I’m not sure about doing that using the jira-python library, but I can help you with Python by accessing the Jira REST API directly.

To update a project role, you can use the following template:

import requests
from requests.auth import HTTPBasicAuth
import json


url = "https://your-domain/rest/api/2/role/{id}"
auth = HTTPBasicAuth("email@example.com", "<password>")

# HTTP headers, indicating that we're sending JSON data
headers = {
"Content-Type": "application/json"
}

# The data to update the role – in this case, the role's name and description
payload = {
"name": "Developers",
"description": "A project role that represents developers in a project"
}

# Make the PUT request to update the role
response = requests.put(url, json=payload, headers=headers, auth=auth)

print(response.status_code)
print(response.json())

I highly recommend checking out the Jira REST API documentation (here) . Since you're just starting with Python, you'll find there's a lot you can do. In most cases, using the library is a time-saver, but knowing the longer path gives you more flexibility and options.

Hope this helps!

 

DEPLOYMENT TYPE
SERVER
VERSION
9.12.15
TAGS
AUG Leaders

Atlassian Community Events