我目前正在使用python JIRA来创建问题。我希望能够在创建问题后向特定的电子邮件地址发送电子邮件。这是我尝试的解决方案,但它不起作用。
jira = JIRA(options,basic_auth=('username@email.com','password'))
jira.email_user('test@email.com', 'test email body', title='JIRA Notification')
但是对email_user的请求给出了404错误。 “哎呀,你找到了一个死链接”。有人知道在创建jira问题时将自定义电子邮件发送到指定电子邮件地址的替代方法吗?我更愿意通过JIRA Rest API来做到这一点。
答案 0 :(得分:0)
如果其他人有此问题,以下是使用JIRA rest api(在python中)发送自定义电子邮件的方法:
import requests
url = "https://jiraserver.atlassian.net/rest/api/2/issue/{issue number or key}/notify"
notify_data = {
"subject": "Duis eu justo eget augue iaculis fermentum.",
"textBody": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
"htmlBody": "Lorem ipsum <strong>dolor</strong> sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
"to": {
"users": [
{
"name": "JIRA user"}] #Make sure you set permission for receiving notifications from self in your profile if you use same user you are logged in as"
},
}
requests.post(url,auth=('jira username','jira password'), json=notify_data)