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

API Post comment with markdown


I’m trying to post a test result using the API that contains a comment with markdown (leading spaces)

Currently, leading whitepsaces are normalized with 1 space which circumvents the markdown. I’m trying to print failed stack trace formatted (markdown) in monospace/code for better readability. Prior to the change to JSON, this use to work.

Is this a limitation with JSON or is there a workaround?



I forgot to mention that it is possible to use the back-tick (`) or the triple back-tick (```) for code/monospaced typeface markdown, however it still removes the white spaces so the Java Stack trace is not aligned.


Hello Costa,

Thanks for your posting and my apologies for the delayed response. We will look into this shortly and I believe this could be a bug/issue with ‘trimming’ the text. I believe one workaround would be to add a separate line of text before the stack trace, e.g.:

[code]Stack trace:

Trace 1..
Trace 2..
Trace 3..




Unfortunately, I tried that and it appears to not work. I parse out each line of the stack trace, add a backtick (`), four white spaces and a new line (\n) which does allow the markdown to work, however the white spaces are removed.

Here’s my Java code:

    private String stringToMarkdown( String stackTrace )
        Scanner scanner = new Scanner( stackTrace );
        String formattedString = "";
        while ( scanner.hasNextLine() )
            formattedString = formattedString + "`    " + scanner.nextLine() + "`\n";
            System.out.println( formattedString );
        return formattedString;

The output is then posted (HttpPost) as part of the comment field.


Thanks for the additional details. We will try to reproduce this here and get back to you then.



When I post a string to the API for the comment field, I can’t get it to create a line break, and none of the rich text formatting options seem to work without a line break. (I’m also trying to post a stack trace to the comment field in a way that is usable). Thanks.


Hi Titus,

Which API binding do you use and how do you format the line break? With most programming languages, you would need to add a "\n" to separate the lines.



Maybe I am reading this topic wrong…

TR stated on Oct 13 2016 issue might be a bug but never got back to OP it seems as 2 YEARS LATER another user adds to this topic and TR response to only last point.

So maybe my install is too old and it is a bug. Can’t tell from this post and TR does not make its bug list public.

What I can tell is here in 2019 I am seeing the same issue as OP. Can’t format the test result comment thru API. Even with a leading line.

TR any idea if this was a bug? Was it fixed? If so which release?


Hey there,

To give a bit of historical context to some of these older forum posts, the Gurock brothers were the original owners, developers, and support team for the entire TestRail system, and managed pretty much everything on their own. With the acquisition of TestRail by Idera, we’ve been working to locate these types of issues that were historically reported and ensure they are on the development radar, or that they were fixed by the original team in a previous release.

When testing API methods myself, I am currently able to correctly format the text including leading spaces and/or tab characters when using a raw JSON format API call through Postman. When setting up the body of the call, I can format it like this:

    "comment": "Initial line, not formatted\n    line break + four leading spaces will just add the line, will not preformat\n\n        Adding two line breaks and the four leading spaces will add formatting\n\n        Two line breaks with eight leading spaces will add a preformatted line with the extra white space\n\n    \t Four leading spaces and a tab character (\t) will also work to add the additional whitespace",

So, this appears to be fixed in my testing, although how you can achieve the correct formatting depends on the API bindings you are using, and may be dependent on the version of TestRail you are using. Unfortunately, I’m not able to give an exact version where this change would have been made as these types of changes were not as well documented prior to the current development and product management teams taking over.