0

I'm trying to create a Jira Issue with python, but while calling the new issue method getting below error, seems i'm missing something or not trying the right way, the fields of report frequency, report request type & due date is mandatory fields. Can anyone help me with the error?

jira.exceptions.JIRAError: JiraError HTTP 400 url: https://neomediaworld.atlassian.net/rest/api/2/issue
    text: Field 'report frequency' cannot be set. It is not on the appropriate screen, or unknown., Field 'report request type' cannot be set. It is not on the appropriate screen, or unknown., Field 'due date' cannot be set. It is not on the appropriate screen, or unknown., Field 'market' cannot be set. It is not on the appropriate screen, or unknown.

    response headers = {'X-AUSERNAME': 'Dharmendra.mishra', 'X-AREQUESTID': '675ecad3-1149-4673-b283-d86a55292d01', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Transfer-Encoding': 'chunked', 'X-Seraph-LoginReason': 'OK', 'Strict-Transport-Security': 'max-age=315360000; includeSubDomains; preload', 'ATL-TraceId': '49a1e4174e1f0c65', 'ATL-TCS-Time': 'Cache Hit', 'Server': 'Atlassian Proxy/1.13.6.2', 'Connection': 'close', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Mon, 29 Oct 2018 08:15:59 GMT', 'Content-Type': 'application/json;charset=UTF-8'}
    response text = {"errorMessages":[],"errors":{"market":"Field 'market' cannot be set. It is not on the appropriate screen, or unknown.","due date":"Field 'due date' cannot be set. It is not on the appropriate screen, or unknown.","report frequency":"Field 'report frequency' cannot be set. It is not on the appropriate screen, or unknown.","report request type":"Field 'report request type' cannot be set. It is not on the appropriate screen, or unknown."}}

The code is as below.

from jira import JIRA
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
import datetime


class JiraException(Exception):
    pass


class Jira(object):

    def __init__(self, **kwargs):

        self.options = {
            'server': 'https://neomediaworld.atlassian.net',
            'verify': False
        }

        self.client = None

        if len(kwargs) != 2:
            raise JiraException(
                'In order to use this class you need to specify a user and a password as keyword arguments!')
        else:
            if 'username' in kwargs.keys():
                self.username = kwargs['username']
            else:
                raise JiraException('You need to specify a username as keyword argument!')
            if 'password' in kwargs.keys():
                self.password = kwargs['password']
            else:
                raise JiraException('You need to specify a password as keyword argument!')

            try:
                self.client = JIRA(self.options, basic_auth=(self.username, self.password))
            except Exception:
                raise JiraException('Could not connect to the API, invalid username or password!')

    def get_projects(self, raw=False):
        projects = []
        for project in self.client.projects():
            if raw:
                projects.append(project)
            else:
                projects.append({'Name': str(project.key), 'Description': str(project.name)})
        return projects

    def new_issue(self):

        issue_dict = {
            'project': {'key': 'MOS'},
            'issuetype': {'name': 'Reporting'},
            'summary': 'Test',
            'market': 'AUS',
            'report request type': 'Ad hoc',
            'report frequency': 'Monthly',
            'description': 'test',
            'due date': '29/Oct/18'}

        new_issue = self.client.create_issue(fields=issue_dict)
DKM
  • 1,761
  • 2
  • 19
  • 34
  • different users can see different views in Jira, so you should make sure the Jira user you are using with the integration has the "report frequency,report request type,due date, market" fields visible or not. – Harsha Biyani Oct 29 '18 at 09:31
  • @HarshaB I'm the user and able to create issue using UI, same implementing using JIRA-Python, but getting the above error, Is there any access or custom filed issue? – DKM Oct 29 '18 at 09:34
  • @HarshaB and when I'm removing the fields getting these fields are required.jira.exceptions.JIRAError: JiraError HTTP 400 url: https://neomediaworld.atlassian.net/rest/api/2/issue text: Report Request Type is required., Report Frequency is required., Market is required., Due date is required. – DKM Oct 29 '18 at 09:37
  • 1
    check availableFields that showing via API https://community.atlassian.com/t5/Jira-questions/How-do-I-get-all-custom-fields-of-an-issue-using-rest-api/qaq-p/538525 – Harsha Biyani Oct 29 '18 at 09:46
  • @HarshaB, I resolved it by passing custom field it here. – DKM Oct 30 '18 at 04:55
  • @HarshaB, One more question - I want to add assignee attachment and watchers while creating the issue on New_Issue method, Could you suggest? – DKM Oct 30 '18 at 04:58

0 Answers0