Skip to end of metadata
Go to start of metadata

Applicable:

JIRA 5.0 and later.

 

The Rest API allows you to create an issue.

The JIRA REST api allows you to easily create an issue. You can POST a single JSON document.

Icon

The examples shown here use curl with an input file denoted by the "--data @filename" syntax and the file data is shown separately

Field meta-data for creating issues

The fields that are available when creating an issue are available via the REST API, e.g.

This will return all of the create metadata for all issue types across all projects.

You most likely want a subset of that information, for example for a specific project and issue type, which you can ask for by specifying the project ids, project names, issue type ids, or issue type names in the URL. For example, to get the create metadata for the Bug issue type in the JRA project:

See the Discovering meta-data for creating issues tutorial for more information

Examples of creating an issue

Example of creating an issue using project keys and field names.

This simple create request

Request
Data
Response

Example of creating an issue using project ids and issue type ids.

Programs using REST may have queried the set of projects and issue ids (for example via createmeta above), and not want to use the names of projects or issue types. They can just as easily use ids, as in the example below:

Request
Data
Response

The response provides the issue id, key, and the URL to the issue (which can then be used to GET additional data, PUT updates, etc) via the REST API.

Example of creating a sub-task

Creating a sub-task is similar to creating a regular issue, with two important differences:

  • the issueType field must correspond to a sub-task issue type (you can use /issue/createmeta to discover sub-task issue types), and
  • you must provide a parent field in the issue create request containing the id or key of the parent issue.

Because a sub-task is essentially a special type of issue, the sub-task creation request and response are very similar to issue creation, as you can see from the following examples.

Request
Data
Response

The response provides the sub-task id, key, and the URL to the issue (which can then be used to GET additional data, PUT updates, etc) via the REST API.

Example of creating an issue using custom fields

Since custom field names are not unique within a JIRA instance, custom fields are referred to by the field ID, in the REST API. The same custom field name would have different ids across different JIRA instances. For example, on one JIRA instance, "Story Points" might have the id "10000" while on another instance the id might be "10101".

In REST in JIRA, customfields are referenced by "customfield_" + the id of the custom field.

So the "Story Points" custom field, with id = "10000", would be referenced as "customfield_10000" for the field name in the JIRA REST API.

If you're looking to always set a specific field, such as "Story Points", you should first GET the createmeta information for the issue type, and then get the appropriate custom field id for that field name.

In the example below, we have a field called "Explanation" that is a Free Text Field in JIRA, and the id of that field is 11050, so we reference the field as "customfield_11050". Notice that the name of the field "Explanation" is not used anywhere.

Request
Data
Response

Again, the issue created is returned in the response.

Examples of how to set custom field data for other field types:

CascadingSelectField

The value associated with "name" ("green" in this example) is the parent option selected, then "blue" is the child option }

DatePickerField

The format is: YYYY-MM-DD

DateTimeField

This format is ISO 8601: YYYY-MM-DDThh:mm:ss.sTZD

FreeTextField
GroupPicker

Like users, groups are specified by name (or id).

Labels

Labels are arrays of strings

MultiGroupPicker

Like users, groups are specified by name, or id.

MultiSelect
MultiUserPicker

Array of users

NumberField

Just a number (not a number in a string)

ProjectPicker

You can also specify the project by project ID

RadioButtons

You can also specify the selection by id

SelectList

You can also specify the selection by id

SingleVersionPicker

You can also specify the version by id

TextField
URLField
UserPicker
VersionPicker

You can also specify a version by id

Adding a worklog entry during create

If you want to set the time tracking fields in a JIRA issue when creating the issue, the create data should include a section like the following:

Time tracking must be enabled to set these fields. In addition, if you are using the JIRA "Legacy" time tracking mode (set by a JIRA Administrator), then only the remaining estimate can be set, so the "originalestimate" field should not be included in the REST request.

Request

No different from any of the other examples, the create is simply a POST:

Data

Again, this data is if Legacy mode for time tracking is off.

Response
  • No labels