Comment a ticket with line breaks

Problem description, when posting a text containing line breaks like below

"description": "Test incident\n\n\nCreated by: Peter Atthem\npeter@rixter.se\n\nImpact: 2 - Medium\nUrgency: 2 - Medium\nPriority: 3 - Moderate",

the request to Jira will fail due to the line breaks. Since it resolves like this

"text": "Test incident Created by: Peter Atthem peter@rixter.se Impact: 2 - Medium Urgency: 2 - Medium Priority: 3 - Moderate", "type": "text"

To solve this use {{{toJSON description}}} to substitute the variable, this will covert the input to safe json string

Add a action with the following details

Method: POST

URL: https://{{baseUrl}}/rest/api/3/issue/{{issueKey}}/comment

Authorization: Atlassian Authorization token

Body:

{ "body": { "type": "doc", "version": 1, "content": [ { "type": "paragraph", "content": [ { "text": {{{toJSON description}}}, "type": "text" } ] } ] } }

Â