Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 21:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to I create na issue using the jira python api

Mont
Contributor
August 12, 2022
I am getting the error message: HTTPError: project: project is required
However I am passing the project id the create_issue method as specified below.  And initialized the jira client.
jira_client = Jira(url='https://jira.domain.com', username='username', password='password', cloud=False)
jira_response = jira-client.create_issue(fields=('project': 'projectId')
Does anyone know how to create an issue passing in the project_id? I followed the documentation I seen but it's appears not to be working.
 

1 answer

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 12, 2022

Hello @Mont 

Welcome to the community.

Can you provide a link to the documentation you are using?

Based on this document

https://buildmedia.readthedocs.org/media/pdf/jira/latest/jira.pdf

...your syntax is incorrect (and you have a typo). The correct syntax would be (minimally)

jira_response = jira_client.create_issue('project'='replaceWithActualProjectId')

And note that you have to provide a valid Project ID value.

However, even that will not be enough as creation of an issue also requires specifying minimally the issue type and text for the Summary field of the issue.

Mont
Contributor
August 12, 2022

Hello, I am using this one. 

https://jira.readthedocs.io/

 

Similar to this in the documentation

issue_dict = {
    'project': {'id': 123},
    'summary': 'New issue from jira-python',
    'description': 'Look into this one',
    'issuetype': {'name': 'Bug'},

 

Except I realized I do not have curly brackets in my project key. I just have the project id. I then tried putting it in curly braces {'id': <project_id>}

But I got the same error.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 12, 2022

If you want to use .create_issue(fields=... then I believe the syntax you'll need is

jira_response = jira_client.create_issue(fields={'project':{'id': <value>},})

Or you need to code like the example where you put the info into a dictionary (i.e. issue_dict) as shown and then provide that dictionary as the value assigned to fields 

Like a.m.gruenenwald likes this
Mont
Contributor
August 12, 2022

Looks Like I get the same message when including project id this way too.

Mont
Contributor
August 12, 2022

Is it possible I may have the wrong url? When I intialize the jira object?

Is there a certain URL I'm suppose to use?

Mont
Contributor
August 12, 2022

I think I found it. When I pass in the project id as a digit it works.

I was thinking the project id the project name. 

 

So the project Id, project name, and project key are all separate variables?

 

When we're passing in the value to the project should it be a string or integer?

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 13, 2022

Looking at the example you pasted in this thread from the documentation, you need to be passing in the project ID, which is an integer.

Suggest an answer

Log in or Sign up to answer