createIssue method

Future<CreatedIssue> createIssue({
  1. bool? updateHistory,
  2. required IssueUpdateDetails body,
})

Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask. A transition may be applied, to move the issue or subtask to a workflow step other than the default start step, and issue properties set.

The content of the issue or subtask is defined using update and fields. The fields that can be set in the issue or subtask are determined using the Get create issue metadata. These are the same fields that appear on the issue's create screen. Note that the description, environment, and any textarea type custom fields (multi-line text fields) take Atlassian Document Format content. Single line custom fields (textfield) accept a string and don't handle Atlassian Document Format content.

Creating a subtask differs from creating an issue as follows:

  • issueType must be set to a subtask issue type (use Get create issue metadata to find subtask issue types).
  • parent must contain the ID or key of the parent issue.

In a next-gen project any issue may be made a child providing that the parent and child are members of the same project.

Permissions required: Browse projects and Create issues project permissions for the project in which the issue or subtask is created.

Implementation

Future<CreatedIssue> createIssue(
    {bool? updateHistory, required IssueUpdateDetails body}) async {
  return CreatedIssue.fromJson(await _client.send(
    'post',
    'rest/api/3/issue',
    queryParameters: {
      if (updateHistory != null) 'updateHistory': '$updateHistory',
    },
    body: body.toJson(),
  ));
}