Hello,
I am working on a script to create jira tickets using the Atlassian library in python.
Following is my script:
from atlassian import Jira
import pandas as pd
from datetime import datetime
results = pd.read_csv('FILENAME')
jira = Jira(
url='https://jira.orgname.org/',
token='TOKEN'
)
fields = { "project": { "key": "PROJECT KEY" },
"summary": "this is the summary",
"description": "this is the description",
"issuetype": { "name": "type" },
"customfield_13308": { "value": "" },
"customfield_13309": { "value": "employee_id" },
"customfield_13310": { "value": "No" },
"customfield_13311": { "value": "No" },
"customfield_13312": { "value": "No" },
"customfield_15904": { "value": "No" },
"customfield_13307": results['amount'].sum(), #Amount
"customfield_13306": len(results), #Rows
"duedate": datetime.today().strftime('%Y-%m-%d'),
"customfield_13315":
}
newIssue = jira.issue_create(fields)
The script appears to work and the ticket is created. But I can not perform further tasks in the script such as updating fields after the ticket creation because the script seems to crash with the following error and log:
File "/Users/username/Desktop/python-code/pythonProjectTest/Thursday/test1.py", line 32, in <module>
newIssue = jira.issue_create(fields)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/atlassian/jira.py", line 1166, in issue_create
return self.post(url, data={"fields": fields})
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/atlassian/rest_client.py", line 309, in post
response = self.request(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/atlassian/rest_client.py", line 242, in request
self.raise_for_status(response)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/atlassian/rest_client.py", line 401, in raise_for_status
raise HTTPError(error_msg, response=response)
requests.exceptions.HTTPError: We can't create this issue for you right now, it could be due to unsupported content you've entered into one or more of the issue fields. If this situation persists, contact your administrator as they'll be able to access more specific information in the log file.
This is weird because the issue does get created and all the fields are populated as expected. Would anyone be able to help me here? Or is this definitely a permissions issue? I was not sure how to describe this problem to admins.
Hi @amaan khan,
I'm not 100% sure, but I would think if you are creating a new ticket you would need to make a second call to edit the created issue in order to update fields that being changed from their initial values.
However, you might find more helpful answers from members of the Developer Community who are more familiar with these types of actions:
https://community.developer.atlassian.com/c/jira/jira-server/8
I hope that helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.