Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

How to post multilines via API?


#1

Hi,

how must the text be formatted, so that I can send multiline text via the API ?

I tried a simple \\n newline symbol, but this is then ignored, also <br>.

e.g. for java I have a simple data object to post to add_case

JSONObject data = new JSONObject();
data.put("steps", "* this do first\\n*This do second"));
data.put("title", "Multiline test");

Thanks


#2

Hi !

In my python scripts a simple \n works very well, for example :


#3

thanks for that… so somehow the \\n inside the java code is not correct then ?!


#4

sorry i’m not good with java but i found someone who have the same problem as you with the jira rest API in JAVA maybe you can try his solution ?

Hope this can help


#5

again thanks for the investigation… Unfortunately it does not help for TestRail.

When I use \\\\n, I still get

Do it\n* Do that

displayed in TestRail


#6

Have you tried \r\n ?


#7

ah damn… this is another “too stupid to do…”

the solution is simple:

JSONObject data = new JSONObject();
data.put("steps", "* this do first\n*This do second"));
data.put("title", "Multiline test");

who could have though of that…


#8

I thought that you have tried this solution when i posted the screenshot of my python script with \n :smile:

Good job guy !


#9

yeah - there are things I will not talk about… jediwave we forget that