How to keep line breaks in announcements?
Any ideas on how to keep the formatting?
Best Answer
-
Tomi_Kaartama Customer IT Monkey ✭OK, found the solution. When building they body, you need to use HTML code like this:
$TestBody = @"
Two lines<br>of body text.<br>
This is going to give you a JSON body as follows:
"Body": "Two lines\u003cbr\u003eof body text.\u003cbr\u003e"
And this will be displayed properly.0
Answers
I haven't tested this specifically, but there are a few things to try off the top of my head:
If the above is going into the contents of an Invoke-RestMethod's URL, they also might need to be encoded to be compatible.
Thanks,
Nick
"Body": "Two linesof body text.",
This is what I get after I give the invoke-rest command as output. You have the line feeds characters present.
However, this is shown on the portal like this:
Another twist to this is that when you open the annoucement from the "Manage Announcement" list, you very briefly see the text on separate lines but then they are shown on one line only. The text on separate lines is shown for such a brief time that I am unable to take a screenshot.
Is your suggestion that I should try to replace "" by "`n" after the JSON conversion?
$TestBody = @"
Two lines<br>
This is going to give you a JSON body as follows:
"Body": "Two lines\u003cbr\u003eof body text.\u003cbr\u003e"
And this will be displayed properly.