Skip to content

Commit 96208a4

Browse files
authored
Merge pull request #26015 from microsoftgraph/users/sumanac/updateforstricthtml
Adding a note and updating examples for documentation
2 parents 7f4efde + bf2e082 commit 96208a4

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

api-reference/beta/api/chatmessage-post.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ If successful, this method returns a `201 Created` response code and a new [chat
7878

7979
In the following examples, the URL can use the [HTTP syntax](#http-request) described to [send a message to a chat](chat-post-messages.md), [send a message to a channel](channel-post-messages.md), or [send reply to a channel](chatmessage-post-replies.md).
8080

81+
> [!NOTE]
82+
> The Teams client has specific HTML restrictions. Therefore, the HTML elements supported by the Microsoft Graph API are compatible with the Teams client. For example, certain elements like `<div>` and inline styles may not function as intended.
83+
8184
### Example 1: Send a Hello World message in a channel
8285

8386
#### Request
@@ -764,7 +767,7 @@ Content-type: application/json
764767
{
765768
"body": {
766769
"contentType": "html",
767-
"content": "<div><div>\n<div><span><img height=\"297\" src=\"../hostedContents/1/$value\" width=\"297\" style=\"vertical-align:bottom; width:297px; height:297px\"></span>\n\n</div>\n\n\n</div>\n</div>"
770+
"content": "<img height=\"297\" src=\"../hostedContents/1/$value\" width=\"297\">"
768771
},
769772
"hostedContents":[
770773
{
@@ -855,7 +858,7 @@ Content-type: application/json
855858
},
856859
"body": {
857860
"contentType": "html",
858-
"content": "<div><div><div><span><img height=\"297\" src=\"https://graph.microsoft.com/beta/chats/19:2da4c29f6d7041eca70b638b43d45437@thread.v2/messages/1616991962672/hostedContents/aWQ9eF8wLXd1cy1kNy1kZTczYzM0YTYzZGVkYjViMDVlNjYyY2Y1NzQ5MGU5Yyx0eXBlPTEsdXJsPWh0dHBzOi8vdXMtYXBpLmFzbS5za3lwZS5jb20vdjEvb2JqZWN0cy8wLXd1cy1kNy1kZTczYzM0YTYzZGVkYjViMDVlNjYyY2Y1NzQ5MGU5Yy92aWV3cy9pbWdv/$value\" width=\"297\" style=\"vertical-align:bottom; width:297px; height:297px\"></span></div></div></div>"
861+
"content": "<img height=\"297\" src=\"https://graph.microsoft.com/v1.0/chats/19:97641583cf154265a237da28ebbde27a@thread.v2/messages/1736180156294/hostedContents/aWQ9eF8wLWV1cy1kMTQtYjUxMDlhMDhkODZkM2ZjODBkNzFlYjUzMWM4ZDlmZGEsdHlwZT0xLHVybD1odHRwczovL3VzLWFwaS5hc20uc2t5cGUuY29tL3YxL29iamVjdHMvMC1ldXMtZDE0LWI1MTA5YTA4ZDg2ZDNmYzgwZDcxZWI1MzFjOGQ5ZmRhL3ZpZXdzL2ltZ3BzaF9mdWxsc2l6ZQ==/$value\" width=\"297\">"
859862
},
860863
"attachments": [],
861864
"mentions": [],
@@ -1034,7 +1037,7 @@ Content-type: application/json
10341037
{
10351038
"body": {
10361039
"contentType": "html",
1037-
"content": "<div><div><at id=\"0\">General</at>&nbsp;Hello there!</div></div>"
1040+
"content": "<at id=\"0\">General</at>&nbsp;Hello there!"
10381041
},
10391042
"mentions": [
10401043
{
@@ -1130,7 +1133,7 @@ Content-type: application/json
11301133
},
11311134
"body": {
11321135
"contentType": "html",
1133-
"content": "<div><div><at id=\"0\">General</at>&nbsp;Hello there!</div></div>"
1136+
"content": "<at id=\"0\">General</at>&nbsp;Hello there!"
11341137
},
11351138
"channelIdentity": {
11361139
"teamId": "68a3e365-f7d9-4a56-b499-24332a9cc572",
@@ -1180,7 +1183,7 @@ Content-type: application/json
11801183
{
11811184
"body": {
11821185
"contentType": "html",
1183-
"content": "<div><div><at id=\"0\">GraphTesting</at>&nbsp;Hello team</div></div>"
1186+
"content": "<at id=\"0\">GraphTesting</at>&nbsp;Hello team"
11841187
},
11851188
"mentions": [
11861189
{
@@ -1278,7 +1281,7 @@ Content-type: application/json
12781281
},
12791282
"body": {
12801283
"contentType": "html",
1281-
"content": "<div><div><at id=\"0\">GraphTesting</at>&nbsp;Hello team</div></div>"
1284+
"content": "<at id=\"0\">GraphTesting</at>&nbsp;Hello team"
12821285
},
12831286
"channelIdentity": {
12841287
"teamId": "68a3e365-f7d9-4a56-b499-24332a9cc572",
@@ -1326,7 +1329,7 @@ Content-type: application/json
13261329
{
13271330
"body": {
13281331
"contentType": "html",
1329-
"content": "<div><div><at id=\"0\">TestTag</at>&nbsp;Testing Tags</div></div>"
1332+
"content": "<at id=\"0\">TestTag</at>&nbsp;Testing Tags"
13301333
},
13311334
"mentions": [
13321335
{
@@ -1421,7 +1424,7 @@ Content-type: application/json
14211424
},
14221425
"body": {
14231426
"contentType": "html",
1424-
"content": "<div><div><at id=\"0\">TestTag</at>&nbsp;Testing Tags</div></div>"
1427+
"content": "<at id=\"0\">TestTag</at>&nbsp;Testing Tags"
14251428
},
14261429
"channelIdentity": {
14271430
"teamId": "fbe2bf47-16c8-47cf-b4a5-4b9b187c508b",
@@ -1623,7 +1626,7 @@ Content-type: application/json
16231626
"id": "d7ddbf876ae340c3a03bada395ec7da7",
16241627
"contentType": "application/vnd.microsoft.teams.messaging-announcementBanner",
16251628
"contentUrl": null,
1626-
"content": "{\"title\":\"Announcement heading\",\"cardImageType\":\"uploadedImage\",\"cardImageDetails\":{\"uploadedImageDetail\":{\"originalImage\":{\"source\":\"../hostedContents/1/$value\",\"width\":1379,\"height\":268,\"croppedWidth\":918.0,\"croppedHeight\":178.4075416968818,\"leftMargin\":0.0,\"topMargin\":90.7962291515591,\"imageContentType\":\"image/png\"},\"croppedImage\":{\"source\":\"../hostedContents/2/$value\"}}}}",
1629+
"content": "{\"title\":\"\",\"cardImageType\":\"uploadedImage\",\"cardImageDetails\":{\"uploadedImageDetail\":{\"originalImage\":{\"source\":\"../hostedContents/2/$value\",\"imageContentType\":\"image/jpg\"},\"croppedImage\":{\"source\":\"../hostedContents/1/$value\"}}}}",
16271630
"name": null,
16281631
"thumbnailUrl": null
16291632
}
@@ -1731,7 +1734,7 @@ Content-type: application/json
17311734
"id": "d7ddbf876ae340c3a03bada395ec7da7",
17321735
"contentType": "application/vnd.microsoft.teams.messaging-announcementBanner",
17331736
"contentUrl": null,
1734-
"content": "{\"title\":\"Announcement heading\",\"cardImageType\":\"uploadedImage\",\"cardImageDetails\":{\"uploadedImageDetail\":{\"originalImage\":{\"source\":\"https://graph.microsoft.com/beta/teams/5c884e2f-83f8-4cff-af8e-0177f260b9f8/channels/19:81f49626414645c99469ee65a1a7e1a4@thread.tacv2/messages/1675104302171/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly91cy1hcGkuYXNtLnNreXBlLmNvbS92MS9vYmplY3RzLzAtd3VzLWQyLTY3OTJlM2ExMzFmNzc4YjY5NWMwYTE5ZGRkZmIwYWNiL3ZpZXdzL2ltZ28=/$value\",\"width\":1379,\"height\":268,\"croppedWidth\":918.0,\"croppedHeight\":178.4075416968818,\"leftMargin\":0.0,\"topMargin\":90.7962291515591,\"imageContentType\":\"image/png\"},\"croppedImage\":{\"source\":\"https://graph.microsoft.com/beta/teams/5c884e2f-83f8-4cff-af8e-0177f260b9f8/channels/19:81f49626414645c99469ee65a1a7e1a4@thread.tacv2/messages/1675104302171/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly91cy1hcGkuYXNtLnNreXBlLmNvbS92MS9vYmplY3RzLzAtd3VzLWQzLTAwYjhhNWZiZTA0MGRmY2MzMWZkNzM1ZDE4Yjk4NTM5L3ZpZXdzL2ltZ28=/$value\"}}}}",
1737+
"content": "{\"title\":\"Test title\",\"cardImageType\":\"uploadedImage\",\"cardImageDetails\":{\"uploadedImageDetail\":{\"originalImage\":{\"source\":\"https://graph.microsoft.com/beta/teams/5c884e2f-83f8-4cff-af8e-0177f260b9f8/channels/19%3A81f49626414645c99469ee65a1a7e1a4%40thread.tacv2/messages/1736180726031/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly91cy1hcGkuYXNtLnNreXBlLmNvbS92MS9vYmplY3RzLzAtd3VzLWQ5LTEzMzNjYzJhOWFlYTdjOWYwMWJmNjc2YWU5YWE3NTdhL3ZpZXdzL2ltZ3BzaF9mdWxsc2l6ZQ==/$value\",\"width\":1317,\"height\":366,\"croppedWidth\":1317.0,\"croppedHeight\":366.0,\"leftMargin\":0.0,\"topMargin\":0.0},\"croppedImage\":{\"source\":\"https://graph.microsoft.com/beta/teams/5c884e2f-83f8-4cff-af8e-0177f260b9f8/channels/19%3A81f49626414645c99469ee65a1a7e1a4%40thread.tacv2/messages/1736180726031/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly91cy1hcGkuYXNtLnNreXBlLmNvbS92MS9vYmplY3RzLzAtd3VzLWQ5LTEzMzNjYzJhOWFlYTdjOWYwMWJmNjc2YWU5YWE3NTdhL3ZpZXdzL2ltZ3BzaF9mdWxsc2l6ZQ==/$value\"}}}}",
17351738
"name": null,
17361739
"thumbnailUrl": null,
17371740
"teamsAppId": null

api-reference/v1.0/api/chatmessage-post.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ If successful, this method returns a `201 Created` response code and a new [chat
7676

7777
In the following examples, the URL can use the [HTTP syntax](#http-request) described to [send a message to a chat](chat-post-messages.md), [send a message to a channel](channel-post-messages.md), or [send reply to a channel](chatmessage-post-replies.md).
7878

79+
> [!NOTE]
80+
> The Teams client has specific HTML restrictions. Therefore, the HTML elements supported by the Microsoft Graph API are compatible with the Teams client. For example, certain elements like `<div>` and inline styles may not function as intended.
81+
7982
### Example 1: Send a Hello World message in a channel
8083

8184
#### Request
@@ -763,7 +766,7 @@ Content-type: application/json
763766
{
764767
"body": {
765768
"contentType": "html",
766-
"content": "<div><div>\n<div><span><img height=\"297\" src=\"../hostedContents/1/$value\" width=\"297\" style=\"vertical-align:bottom; width:297px; height:297px\"></span>\n\n</div>\n\n\n</div>\n</div>"
769+
"content": "<img height=\"297\" src=\"../hostedContents/1/$value\" width=\"297\">"
767770
},
768771
"hostedContents":[
769772
{
@@ -853,7 +856,7 @@ Content-type: application/json
853856
},
854857
"body": {
855858
"contentType": "html",
856-
"content": "<div><div><div><span><img height=\"297\" src=\"https://graph.microsoft.com/v1.0/chats/19:2da4c29f6d7041eca70b638b43d45437@thread.v2/messages/1616991962672/hostedContents/aWQ9eF8wLXd1cy1kNy1kZTczYzM0YTYzZGVkYjViMDVlNjYyY2Y1NzQ5MGU5Yyx0eXBlPTEsdXJsPWh0dHBzOi8vdXMtYXBpLmFzbS5za3lwZS5jb20vdjEvb2JqZWN0cy8wLXd1cy1kNy1kZTczYzM0YTYzZGVkYjViMDVlNjYyY2Y1NzQ5MGU5Yy92aWV3cy9pbWdv/$value\" width=\"297\" style=\"vertical-align:bottom; width:297px; height:297px\"></span></div></div></div>"
859+
"content": "<img height=\"297\" src=\"https://graph.microsoft.com/v1.0/chats/19:97641583cf154265a237da28ebbde27a@thread.v2/messages/1736180156294/hostedContents/aWQ9eF8wLWV1cy1kMTQtYjUxMDlhMDhkODZkM2ZjODBkNzFlYjUzMWM4ZDlmZGEsdHlwZT0xLHVybD1odHRwczovL3VzLWFwaS5hc20uc2t5cGUuY29tL3YxL29iamVjdHMvMC1ldXMtZDE0LWI1MTA5YTA4ZDg2ZDNmYzgwZDcxZWI1MzFjOGQ5ZmRhL3ZpZXdzL2ltZ3BzaF9mdWxsc2l6ZQ==/$value\" width=\"297\">"
857860
},
858861
"attachments": [],
859862
"mentions": [],
@@ -1031,7 +1034,7 @@ Content-type: application/json
10311034
{
10321035
"body": {
10331036
"contentType": "html",
1034-
"content": "<div><div><at id=\"0\">General</at>&nbsp;Hello there!</div></div>"
1037+
"content": "<at id=\"0\">General</at>&nbsp;Hello there!"
10351038
},
10361039
"mentions": [
10371040
{
@@ -1127,7 +1130,7 @@ Content-type: application/json
11271130
},
11281131
"body": {
11291132
"contentType": "html",
1130-
"content": "<div><div><at id=\"0\">General</at>&nbsp;Hello there!</div></div>"
1133+
"content": "<at id=\"0\">General</at>&nbsp;Hello there!"
11311134
},
11321135
"channelIdentity": {
11331136
"teamId": "68a3e365-f7d9-4a56-b499-24332a9cc572",
@@ -1177,7 +1180,7 @@ Content-type: application/json
11771180
{
11781181
"body": {
11791182
"contentType": "html",
1180-
"content": "<div><div><at id=\"0\">GraphTesting</at>&nbsp;Hello team</div></div>"
1183+
"content": "<at id=\"0\">GraphTesting</at>&nbsp;Hello team"
11811184
},
11821185
"mentions": [
11831186
{
@@ -1275,7 +1278,7 @@ Content-type: application/json
12751278
},
12761279
"body": {
12771280
"contentType": "html",
1278-
"content": "<div><div><at id=\"0\">GraphTesting</at>&nbsp;Hello team</div></div>"
1281+
"content": "<at id=\"0\">GraphTesting</at>&nbsp;Hello team"
12791282
},
12801283
"channelIdentity": {
12811284
"teamId": "68a3e365-f7d9-4a56-b499-24332a9cc572",
@@ -1475,7 +1478,7 @@ Content-type: application/json
14751478
"id": "d7ddbf876ae340c3a03bada395ec7da7",
14761479
"contentType": "application/vnd.microsoft.teams.messaging-announcementBanner",
14771480
"contentUrl": null,
1478-
"content": "{\"title\":\"Announcement heading\",\"cardImageType\":\"uploadedImage\",\"cardImageDetails\":{\"uploadedImageDetail\":{\"originalImage\":{\"source\":\"../hostedContents/1/$value\",\"width\":1379,\"height\":268,\"croppedWidth\":918.0,\"croppedHeight\":178.4075416968818,\"leftMargin\":0.0,\"topMargin\":90.7962291515591,\"imageContentType\":\"image/png\"},\"croppedImage\":{\"source\":\"../hostedContents/2/$value\"}}}}",
1481+
"content": "{\"title\":\"\",\"cardImageType\":\"uploadedImage\",\"cardImageDetails\":{\"uploadedImageDetail\":{\"originalImage\":{\"source\":\"../hostedContents/2/$value\",\"imageContentType\":\"image/jpg\"},\"croppedImage\":{\"source\":\"../hostedContents/1/$value\"}}}}",
14791482
"name": null,
14801483
"thumbnailUrl": null
14811484
}
@@ -1583,7 +1586,7 @@ Content-type: application/json
15831586
"id": "d7ddbf876ae340c3a03bada395ec7da7",
15841587
"contentType": "application/vnd.microsoft.teams.messaging-announcementBanner",
15851588
"contentUrl": null,
1586-
"content": "{\"title\":\"Announcement heading\",\"cardImageType\":\"uploadedImage\",\"cardImageDetails\":{\"uploadedImageDetail\":{\"originalImage\":{\"source\":\"https://graph.microsoft.com/beta/teams/5c884e2f-83f8-4cff-af8e-0177f260b9f8/channels/19:81f49626414645c99469ee65a1a7e1a4@thread.tacv2/messages/1675104302171/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly91cy1hcGkuYXNtLnNreXBlLmNvbS92MS9vYmplY3RzLzAtd3VzLWQyLTY3OTJlM2ExMzFmNzc4YjY5NWMwYTE5ZGRkZmIwYWNiL3ZpZXdzL2ltZ28=/$value\",\"width\":1379,\"height\":268,\"croppedWidth\":918.0,\"croppedHeight\":178.4075416968818,\"leftMargin\":0.0,\"topMargin\":90.7962291515591,\"imageContentType\":\"image/png\"},\"croppedImage\":{\"source\":\"https://graph.microsoft.com/beta/teams/5c884e2f-83f8-4cff-af8e-0177f260b9f8/channels/19:81f49626414645c99469ee65a1a7e1a4@thread.tacv2/messages/1675104302171/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly91cy1hcGkuYXNtLnNreXBlLmNvbS92MS9vYmplY3RzLzAtd3VzLWQzLTAwYjhhNWZiZTA0MGRmY2MzMWZkNzM1ZDE4Yjk4NTM5L3ZpZXdzL2ltZ28=/$value\"}}}}",
1589+
"content": "{\"title\":\"Test title\",\"cardImageType\":\"uploadedImage\",\"cardImageDetails\":{\"uploadedImageDetail\":{\"originalImage\":{\"source\":\"https://graph.microsoft.com/beta/teams/5c884e2f-83f8-4cff-af8e-0177f260b9f8/channels/19%3A81f49626414645c99469ee65a1a7e1a4%40thread.tacv2/messages/1736180726031/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly91cy1hcGkuYXNtLnNreXBlLmNvbS92MS9vYmplY3RzLzAtd3VzLWQ5LTEzMzNjYzJhOWFlYTdjOWYwMWJmNjc2YWU5YWE3NTdhL3ZpZXdzL2ltZ3BzaF9mdWxsc2l6ZQ==/$value\",\"width\":1317,\"height\":366,\"croppedWidth\":1317.0,\"croppedHeight\":366.0,\"leftMargin\":0.0,\"topMargin\":0.0},\"croppedImage\":{\"source\":\"https://graph.microsoft.com/beta/teams/5c884e2f-83f8-4cff-af8e-0177f260b9f8/channels/19%3A81f49626414645c99469ee65a1a7e1a4%40thread.tacv2/messages/1736180726031/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly91cy1hcGkuYXNtLnNreXBlLmNvbS92MS9vYmplY3RzLzAtd3VzLWQ5LTEzMzNjYzJhOWFlYTdjOWYwMWJmNjc2YWU5YWE3NTdhL3ZpZXdzL2ltZ3BzaF9mdWxsc2l6ZQ==/$value\"}}}}",
15871590
"name": null,
15881591
"thumbnailUrl": null,
15891592
"teamsAppId": null

0 commit comments

Comments
 (0)