Post Comments With API, But Keep Text Formatting


We are currently having an issue where we are uploading items to SG via an internal tool, but when we are populating the Description column it has been stripping the text formatting. I also tried updating an item on SG directly with the SG API and it is still stripping the formatting. We were having issues with non-ascii items on our farm but that has been resolved, so I wonder if this is the case here as well under the hood.

For example, this comment:

-Here is a comment
    -And a sub-comment*

Will be posted as:
-Here is a comment -And a sub-comment

Is there something we are missing for us to have it keep the formatting when we upload/update SG items? In the past when debugging this it was working when we would type in directly using the site or copy/paste formatting. However, now this is not the case and it will strip formatting. So we know in some way it was supported, at least on the front end.

Thank you!

1 Like


In order to keep the formatting you’d need to use escape codes.
For your example you’d need to supply this string to your update function

-Here is a comment\n\t-And a sub-comment*

Resulting in the following being displayed on Shotgrid


Escape code cheatsheet
\n - New line
\t - Tab
\' - Single Quote
\" - Double Quote

1 Like

Aha, I believe that is what was missing. Users are not inputting these (as expected) and the tool is not capturing these escape codes it seems, so this is most likely the solution.
I will give this a shot, thanks!


I gave this a shot and ensured that the text had escape characters and it still did not keep the formatting when it creates the version on SG.

I changed my QTextEdit to use a QTextDocument object with the QTextOption ShowTabsAndSpaces applied (which did have formatting in it), which captured all the desired characters. Even the description is formatted correctly on the farm; we copy the comment in this case for easier tracking.

I am not sure what process is stripping the characters when posting with the SG API…I also checked the toPlainText() call that QLineEdit has and that is also not the issue, as it grabbed the string as seen on the farm (screenshots below).

I added screenshots below to show what I mean, let me know if you need more information to try and debug this!



On SG after processing (incorrect formatting)

All steps before processing, with correct formatting intact:

In Tool

Arg on Farm (NDA imformation removed)

Farm Job Comment