Newline in Teams Chat message via graph API

saurabh kumar 5 Reputation points
2023-06-28T17:24:20.35+00:00

I am trying to use the Microsoft Graph Api "https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http". Where I have a chat and now i am posting the message as below (content-type: application/json)

"Line 1 <br /> Line 2"

However in teams chat it shows like "Line 1 Line 2". Newline/break is not working in chat and I have tried various options to get a new line like \n, \r\n, \n, <br/>\n.... but no luck

Any leads will be helpful.

Thanks for the help in advance

Microsoft Security Microsoft Graph
Microsoft Teams Microsoft Teams for business Other
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. msft-gu 1,355 Reputation points
    2023-06-28T19:25:32.3633333+00:00

    Hi Saurabh,

    Good afternoon and thank you for your question. I tried to reproduce this on my end, and I was able to do a new line:

    {
        "body": {
            "contentType": "html",
            "content": "Hello World <br/>New Line Test"
        }
    }
    
    
    

    If it does help you, please accept it as an answer and upvote it. Thank you in advance!

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.