Inline Style for sending chat message to team via api does not work

Yang 0 Reputation points
2024-11-08T21:56:09.94+00:00

I am using this api
POST /chats/{chat-id}/messages

My code

	messageContent = ` <div style="color: #5d9e52; font-weight: bold;">This is a test</div>`;

	const chatMessage = {
		body: {
			contentType: 'html',
			content: `${messageContent}`
		},
		hostedContents: formattedAttachments,
		importance
	};
		const response = await ms.api(`/chats/${chatId}/messages`).post(chatMessage);

So this used to work on Nov 7th 2024 but now the inline style does not work and it only adds basic html content to the teams.

User's image

Any idea why this is not working anymore?

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,445 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,395 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Prasad-MSFT 7,316 Reputation points Microsoft Vendor
    2024-11-11T06:37:29.6766667+00:00

    Yang we tried with this style (the one you tried) and the content rendered as below:

    {
        "body": {
            "contentType": "html",
            "content": "<span style=\"color: #5d9e52; font-weight: bold;\">This is a test</span>"
        }
    }
    

    User's image

    And on changing the style as below, the content rendered with coloured text but without bold.

    {
        "body": {
            "contentType": "html",
            "content": "<span style=\"color: #5d9e52; font-weight: bold;\">This is a test</span>"
        }
    }
    

    User's image

    Thereafter on further modification, we got the content rendering as desired i.e. coloured bold text.

    {
        "body": {
            "contentType": "html",
            "content": "<span style=\"color: green; font-weight: bold;\">This is a test</span>"
        }
    }
    

    User's image


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.