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?
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!
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!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.