Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Multiline comment on pull request via API 2.0

I am trying to post a comment that includes newlines to a pull request using 


My request body looks like this: 

{"content":{"raw":"Report\nTotal Files Examined: 20\nLooks Good!"}}

I would expect the UI comment to look like this:

Total Files Examined: 20
Looks Good!

The request is accepted, but the output in the pull request looks like this:

Report Total Files Examined: 20 Looks Good!

If I open the HTML of the PR page, I see the following:

Total Files Examined: 20
Looks Good!</p>

I believe what is happening is that the raw content is always being pasted into the <p> tags, but what *should* happen is every newline is converted into a new <p> tag. 


I have also tried using \\n and <br>, \\n turns into this in the UI

Report\nTotal Files Examined: 20\nLooks Good!

and <br> turns into this:

Report<br>Total Files Examined: 20<br>Looks Good!


Is there any way around this? I need to UI to respect the line breaks somehow.

1 answer

1 accepted

1 vote
Answer accepted

I discovered I can send using markdown and am using " \n" (space and newline) to make line breaks, this creates the multilines as I want.

###Report \nTotal Files Examined: 20 \nLooks Good!



Total Files Examined: 20
Looks Good!

How did you get this to work? I'm trying to send markdown and it's not working. I tried specifying that it is markup and this results in an error: "This is a test\nthis is only a test\n\`here is some code\`"

{"content":{"raw":"This is a test\nthis is only a test\n`here is some code`","markup":"markdown"}}

{"type": "error", "error": {"fields": {"content.markup": "extra keys not allowed"}, "message": "Bad request"}}

@Charles Hudak The API docs seem to be incorrect (though they're correct for the UI API).


I sent as raw without a markup parameter and as I said above with a space character before the newline.


So in your case: 

{"content":{"raw":"This is a test\nthis is only a test\n`here is some code`","markup":"markdown"}}


{"content":{"raw":"This is a test \nthis is only a test \n`here is some code`"}}


That should work

I tried that (space before newline) and it didn't make a difference.

the "extra keys" is due to the markup parameter. In my example I am also removing it. Did you do that too?

Yep...the comment posted but there were no line breaks...just run on text.

@Charles Hudak any luck with that multiline text? I've tried without success, I do send text as markup and it's rendered as markup but no line breaks (API 2.0).

-d '{"content":{"raw":"**Result** \nDeployed."}}'

-d '{"content":{"raw":"**Result** \n  \nDeployed."}}'

New-line is created by \n##\n where # is space

Like Anton Plebanovich likes this

Two spaces worked for me, thanks!

Unfortunately, two spaces didn't work for me but \n\r works:

curl --request POST --header 'Content-Type:application/json' -d '{"content":{"raw": "line 1\n\rline 2"}}'$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pullrequests/$BITBUCKET_PR_ID/comments?access_token=$ACCESS_TOKEN

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events