From 89d9a7e871f04b53e608c6cc63d348fbce261409 Mon Sep 17 00:00:00 2001 From: Antanina Druzhkina Date: Mon, 6 Oct 2025 01:10:23 +0400 Subject: [PATCH] Fix special characters encoding in ListItemComments --- src/controls/listItemComments/hooks/useSpAPI.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/controls/listItemComments/hooks/useSpAPI.ts b/src/controls/listItemComments/hooks/useSpAPI.ts index 498d6939b..ab0fbf877 100644 --- a/src/controls/listItemComments/hooks/useSpAPI.ts +++ b/src/controls/listItemComments/hooks/useSpAPI.ts @@ -5,6 +5,7 @@ import { IlistItemCommentsResults } from "./../models"; import { IAddCommentPayload } from "../models/IAddCommentPayload"; import { IComment } from "../components/Comments/IComment"; import { PageContext } from "@microsoft/sp-page-context"; +import { GeneralHelper } from '../../../common/utilities/GeneralHelper'; interface returnObject { getListItemComments: () => Promise; getNextPageOfComments: ( @@ -53,9 +54,10 @@ export const useSpAPI = (): returnObject => { webUrl ?? _webUrl }/_api/web/lists(@a1)/GetItemById(@a2)/Comments()?@a1='${listId}'&@a2='${itemId}'`; const spOpts: ISPHttpClientOptions = { - body: `{ "text": "${comment.text}", "mentions": ${JSON.stringify( - comment.mentions - )}}`, + body: JSON.stringify({ + text: GeneralHelper.encodeText(comment.text), + mentions: comment.mentions + }), }; const _listResults: SPHttpClientResponse = await spHttpClient.post( `${_endPointUrl}`,