Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,362,539
Community Members
 
Community Events
168
Community Groups

How to I create na issue using the jira python api

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

Hello @Milton_EllisonJr 

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.

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.

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 

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

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?

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?

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
TAGS

Atlassian Community Events