How to split lines when sending data with the Jira REST API

Still need help?

The Atlassian Community is here for you.

Ask the community

The content on this page relates to platforms which are not supported. Consequently, Atlassian Support cannot guarantee providing any support for it. Please be aware that this material is provided for your information only and using it is done so at your own risk.

Purpose

Provide guidance on splitting lines using the Jira REST API. The method works with both Jira Cloud and Jira Service Management REST APIs for endpoints such as Create issue or Create customer request.

Solution

To split a line of text, the new line character can be used: \n in the appropriate field. In the example below, the Description field's text is split into two lines between the words issue and using:

{
  "fields": {
    "issuetype": {
      "name": "Bug"
    },
    "project": {
      "key": "TEST"
    },
    "summary": "Issue created via REST API",
    "description": {
      "content": [
        {
          "content": [
            {
              "text": "Creating of an issue\nusing project keys and issue type names using the REST API",
              "type": "text"
            }
          ],
          "type": "paragraph"
        }
      ],
      "type": "doc",
      "version": 1
    }
  }
}


To test the above snippet, the following cURL command can be used with the Jira Cloud REST API endpoint:

curl --location 'https://your-site.atlassian.net/rest/api/3/issue' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ••••••' \
--data '{
  "fields": {
    "issuetype": {
      "name": "Bug"
    },
    "project": {
      "key": "TEST"
    },
    "summary": "Issue created via REST API",
    "description": {
      "content": [
        {
          "content": [
            {
              "text": "Creating of an issue\nusing project keys and issue type names using the REST API",
              "type": "text"
            }
          ],
          "type": "paragraph"
        }
      ],
      "type": "doc",
      "version": 1
    }
  }
}'


Testing with the Jira Service Management Cloud REST API endpoint for request creation. In this example the Description field is not using ADF formatting:

curl --location 'https://your-site.atlassian.net/rest/servicedeskapi/request' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ••••••' \
--data '{
    "isAdfRequest": false,
    "requestFieldValues": {
    "description": "Creating of an issue\nusing project keys and issue type names using the REST API",
    "summary": "Request created via REST API"
  },
    "requestTypeId": "855",
    "serviceDeskId": "63"
}'
Last modified on Jan 31, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.