I'm new to both jira and python and I'm trying to create an issue through jira-python and got this error:
TypeError: Object of type User is not JSON serializable
I've tried to remove some fields but still I got the same error and have no idea what I did wrong. I am able to retrieve all those fields from an existing issue.
I know there is a lot of similar questions but none is really helpful
Here is my code:
python
chapeauId='XXXXX'
jiraChapeau= jira.issue(chapeauId)
summary = "socle serveur pour le projet d'automatisation"
description ="Une description regroupant les paramètres du socle"
issueType="T-065"
priority='Mineur'
zoneReseau='XXXXXXX'
cPT= jiraChapeau.fields.reporter
issueDict={
'project': {'key': "AB-01"},
'parent': chapeauId,
'summary': summary,
'description': description,
'priority': priority,
'issuetype': {'name':issueType},
'customfield_13034': zoneReseau,
'customfield_10490' : cPT,
}
newIssue=jira.create_issue(fields=issueDict)
TypeError: Object of type User is not JSON serializable
I assume you're doing the authentication but not showing it? Here is an example on how to create an issue. My guess is your reporter value isn't working because that's the only user related thing I see. I'd check what value you get for jiraChapeau.fields.reporter. It might be more than than just an email. What is your 'customfield_10490'? Probably doesn't like whatever fields.reporter
jira = JIRA(basic_auth=(jira_username, jira_token), options
= {'server':'https://'+jira_domain+'.atlassian.net'})
issue_dict = {
'project' : {'key':'ITS'},
'summary' : 'Store JIRA Backup',
'assignee': {'name': 'user_email_address_goes_here'},
'issuetype': {'name':'Service Request'},
'description': 'Create and download the JIRA backup and store on S: Drive (until
another location for cloud storage backups is determined)',
'components': [{'name': 'JIRA'}],
}
jira.create_issue(issue_dict)