2

Can't open new defect in Jira Via Python (3.6 - Jira Module)

This is my Code:

issue_dict = {
  'project': {'key': 'DET'},
  'summary': 'New issue from jira-python',
  'description': 'Look into this one',
  'issuetype': {'name': 'Defect'},
  'Severity': {'name' : 'High'},
  'defecttype': {'name': 'Performance'},
  'affectsversion/s': {'name': 'test'},
  'testingstream': {'name': 'CET'},
}

new_issue = jira.create_issue(fields=issue_dict)

I'm Getting error message on 4 specific fields that exist in Jira issues and defect screen and also the options are valid on jira,

Severity

testingstream

affectsversion/s

defecttype

This is my error message:

JiraError HTTP 400 url: https://jira/rest/api/2/issue text: Field 'testingstream' cannot be set. It is not on the appropriate screen, or unknown., Field 'Severity' cannot be set. It is not on the appropriate screen, or unknown., Field 'affectsversion/s' cannot be set. It is not on the appropriate screen, or unknown., Field 'defecttype' cannot be set. It is not on the appropriate screen, or unknown. response headers = {'X-AREQUESTID': '769x4311733x3', 'X-ASESSIONID': '5wjfnu', 'X-ANODEID': 'node1', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': "frame-ancestors 'self'", 'X-ASEN': 'SEN-7160564', 'X-Seraph-LoginReason': 'OK', 'X-AUSERNAME': 'user', 'Cache-Control': 'no-cache, no-store, no-transform', 'Content-Encoding': 'gzip', 'Vary': 'User-Agent', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Date': 'Wed, 28 Nov 2018 10:49:44 GMT', 'Connection': 'close'} response text = {"errorMessages":[],"errors":{"testingstream":"Field 'testingstream' cannot be set. It is not on the appropriate screen, or unknown.","Severity":"Field 'Severity' cannot be set. It is not on the appropriate screen, or unknown.","affectsversion/s":"Field 'affectsversion/s' cannot be set. It is not on the appropriate screen, or unknown.","defecttype":"Field 'defecttype' cannot be set. It is not on the appropriate screen, or unknown."}}

Does anyone know what can possibly go wrong?

Thanks in advance!

1 Answer 1

1

Your fields are not standard. They are custom fields. To get mapping you should make request:

from pprint import pprint
allfields = jira.fields()
name_map = {field['name']:field['id'] for field in allfields}
pprint(name_map)

When you have the mapping you can create an issue using code:

    new_issue = jira.create_issue(fields={name_map['Severity']: {'value': 'Minor'}, 'project': 'DET', 'issuetype': 'Defect', 'summary': 'New issue from jira-python'})

Hope, I helped :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.