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.