Reputation: 55
I'm trying to assign a existing jira ticket using python. Tried the below methods , but none are working. I'm able to add comments but not assign the issue
#Method 1 Using Jira library - Getting JiraError HTTP None, text list index out of range
from jira import JIRA
jira_connection = JIRA(basic_auth=(username,password),server)
issue = jira_connection.issue('100')
jira_connection.assign_issue(issue,user_name)
#Tried below way as well
issue.update(assignee={'accountId':'natash5'})
#Method 2 Using Servicedesk - the update_issue_field function was empty in the source code
from atlassian import ServiceDesk
sd = ServiceDesk(url= "")
sd.update_issue_field('100',{'assignee':'user_name')
#Method 3 Soap API - SAXParse exception invalid token
from suds import Client
cl = Client(url)
auth = cl.service.login(username,password)
Upvotes: 1
Views: 1277
Reputation: 88
import psutil
import socket
from datetime import datetime
def get_running_processes(name=None):
process_list = [] # Use a list to store processes
hostname = socket.gethostname() # Get the hostname of the machine
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') # Get current datetime as a string
for process in psutil.process_iter(['pid', 'name', 'username']):
try:
process_info = process.as_dict(attrs=['pid', 'name', 'username'])
if name is None or process_info['name'] == name:
process_info['hostname'] = hostname
process_info['timestamp'] = current_time
process_info['status'] = 'Not Available' if process_info['name'] == 'notepad.exe' else 'Available'
process_list.append(process_info)
except psutil.NoSuchProcess:
pass
return process_list
if __name__ == "__main__":
processes_list = get_running_processes(name="notepad.exe")
print(processes_list)
Upvotes: 0
Reputation: 89
import requests
from requests.auth import HTTPBasicAuth
import json
url = "https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/assignee"
auth = HTTPBasicAuth("[email protected]", "<api_token>")
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
payload = json.dumps( {
"accountId": "5b10ac8d82e05b22cc7d4ef5"
} )
response = requests.request(
"PUT",
url,
data=payload,
headers=headers,
auth=auth
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
I've run into the same issue, use the endpoints yourself rather than the - https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-assignee-put If you're interested I'm putting together a repo that has a lot of this stuff in it with ways to get stuff done. There is still a lot to tidy up in it so conceder this a beta release :) https://github.com/dren79/JiraScripting_public
Upvotes: 1