Create a new issue and return an issue Resource for it.

        Each keyword argument (other than the predefined ones) is treated as a field name and the argument's value
        is treated as the intended value for that field -- if the fields argument is used, all other keyword arguments
        will be ignored.

        By default, the client will immediately reload the issue Resource created by this method in order to return
        a complete Issue object to the caller; this behavior can be controlled through the 'prefetch' argument.

        JIRA projects may contain many different issue types. Some issue screens have different requirements for
        fields in a new issue. This information is available through the 'createmeta' method. Further examples are
        available here: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue

        :param fields: a dict containing field names and the values to use. If present, all other keyword arguments
            will be ignored
        :type fields: Optional[Dict[str, Any]]
        :param prefetch: whether to reload the created issue Resource so that all of its data is present in the value
            returned from this method
        :type prefetch: bool
        :rtype: Issue

def create_issue(self, fields=None, prefetch=True, **fieldargs):
        """Create a new issue and return an issue Resource for it.

        Each keyword argument (other than the predefined ones) is treated as a field name and the argument's value
        is treated as the intended value for that field -- if the fields argument is used, all other keyword arguments
        will be ignored.

        By default, the client will immediately reload the issue Resource created by this method in order to return
        a complete Issue object to the caller; this behavior can be controlled through the 'prefetch' argument.

        JIRA projects may contain many different issue types. Some issue screens have different requirements for
        fields in a new issue. This information is available through the 'createmeta' method. Further examples are
        available here: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue

        :param fields: a dict containing field names and the values to use. If present, all other keyword arguments
            will be ignored
        :type fields: Optional[Dict[str, Any]]
        :param prefetch: whether to reload the created issue Resource so that all of its data is present in the value
            returned from this method
        :type prefetch: bool
        :rtype: Issue
        """
        data = _field_worker(fields, **fieldargs)

        p = data['fields']['project']

        if isinstance(p, string_types) or isinstance(p, integer_types):
            data['fields']['project'] = {'id': self.project(p).id}

        p = data['fields']['issuetype']
        if isinstance(p, integer_types):
            data['fields']['issuetype'] = {'id': p}
        if isinstance(p, string_types) or isinstance(p, integer_types):
            data['fields']['issuetype'] = {'id': self.issue_type_by_name(p).id}

        url = self._get_url('issue')
        r = self._session.post(url, data=json.dumps(data))

        raw_issue_json = json_loads(r)
        if 'key' not in raw_issue_json:
            raise JIRAError(r.status_code, response=r, url=url, text=json.dumps(data))
        if prefetch:
            return self.issue(raw_issue_json['key'])
        else:
            return Issue(self._options, self._session, raw=raw_issue_json)