Jira UI does not format text properly when sending a payload via API

Felipe Delatorre
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 12, 2025

Hello, 

 

Im trying to send an API Post request to `/comments` with the contents of a link. When the link content contains brackets the formatting breaks. This does not happened when using the UI to create a link (see test-2). But when using the API and sending the exact payload the UI does not format it properly (see test-3). 

Below is the response when retrieving those two comments using the API we can see they are identical, yet they are displaying differently.

 

Could I get example payload of what I could send to achieve the results of test-2? I have tried escaping it in different ways with no good results. 

Thank you!

Screenshot 2025-02-12 at 11.04.31 AM.png

{

"body": "[[test-3]|https://www.warp.dev/terminus/post-json-data-with-curl]",

"renderedBody": "<p>[<span class=\"error\">&#91;test-3&#93;</span>|https://www.warp.dev/terminus/post-json-data-with-curl]</p>"

},

{

"body": "[[test-2]|https://www.warp.dev/terminus/post-json-data-with-curl]",

"renderedBody": "<p>[<span class=\"error\">&#91;test-2&#93;</span>|https://www.warp.dev/terminus/post-json-data-with-curl]</p>"

}

1 answer

0 votes
Gerusa Lobo _e-Core_
Atlassian Partner
February 12, 2025

Hello @Felipe Delatorre 

 

There is a difference between Version 2 and 3 for the API for jira cloud comments.

 

In version 2, the comments payload uses a markdown format.

POST {url}/rest/api/2/issue/{issueIdOrKey}/comment

{
"body": "Lorem ipsum"
}

Add Comment v2 

 

In version 3, the payload use a json format, allow more details divide blocks with text, links, media, and other types.

POST {url}/rest/api/3/issue/{issueIdOrKey}/comment

{
"body": {
    "content": [
         {
             "content": [
                     {
                           "text": "Test 123",
"type": "text"
}
],
"type": "paragraph"
}
],
"type": "doc",
"version": 1
}
}

Add Comment v3 

 

You can see the correct format, using in browser the issue endpoint, as example in bellow:

Captura de Tela 2025-02-12 às 17.31.17.png

Using version 2: https://{url}.atlassian.net/rest/api/2/issue/{issuekey}

Captura de Tela 2025-02-12 às 17.33.25.png

And using version 3: https://{url}.atlassian.net/rest/api/3/issue/{issuekey}

Captura de Tela 2025-02-12 às 17.35.59.png

I hope help you.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events