Teams Graph API: Send multiline chat message (JSON content type)

Francois De La Roche 21 Reputation points
2022-02-10T21:23:04.397+00:00

Hello there,

I'm having issue sending a multiline chat message in Microsoft Teams using the Graph API, I'm using this as reference: https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http

Sending a message (via Postman) works, the example in page above gives this result:

173303-image.png

But as soon as I try to introduce a line feed (or line return):

   {  
     "body": {  
       "content": "Hello World \nNew Line"  
     }  
   }  

I'm always getting:

173293-image.png

Things I have tried:

  • \r\n
  • \n\r
  • \n\n
  • \n+space+\n
  • 3 spaces+\n
  • <br>\n
  • and probably others...

Would you be kind to let me know how to add a new line?

Thank you,
Francois

Microsoft Security | Microsoft Graph
Microsoft Teams | Microsoft Teams for business | Other
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,761 Reputation points Microsoft External Staff
    2022-02-11T06:22:01.967+00:00

    Hi @Francois De La Roche ,

    Based on my test using "contentType": "html" will post the chat message in new line. Refer to the below sample request payload I used for my test.

    POST /teams/{team-id}/channels/{channel-id}/messages  
    {  
        "body": {  
            "contentType": "html",  
            "content": "Hello world<br/>New Line"  
        }  
    }  
    

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    source: chatmessage-post

    2 people found this answer helpful.

0 additional answers

Sort by: Most 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.