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

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 Leaders.
April 5, 2025 edited

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!

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.15
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events