Skip to content

Commit 0c1097c

Browse files
authored
Merge pull request #2052 from Ateina/2047-ListItemComments-special-characters-issue
Fix special characters encoding in ListItemComments. Closes #2047
2 parents 1b33079 + 89d9a7e commit 0c1097c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/controls/listItemComments/hooks/useSpAPI.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { IlistItemCommentsResults } from "./../models";
55
import { IAddCommentPayload } from "../models/IAddCommentPayload";
66
import { IComment } from "../components/Comments/IComment";
77
import { PageContext } from "@microsoft/sp-page-context";
8+
import { GeneralHelper } from '../../../common/utilities/GeneralHelper';
89
interface returnObject {
910
getListItemComments: () => Promise<IlistItemCommentsResults>;
1011
getNextPageOfComments: (
@@ -53,9 +54,10 @@ export const useSpAPI = (): returnObject => {
5354
webUrl ?? _webUrl
5455
}/_api/web/lists(@a1)/GetItemById(@a2)/Comments()?@a1='${listId}'&@a2='${itemId}'`;
5556
const spOpts: ISPHttpClientOptions = {
56-
body: `{ "text": "${comment.text}", "mentions": ${JSON.stringify(
57-
comment.mentions
58-
)}}`,
57+
body: JSON.stringify({
58+
text: GeneralHelper.encodeText(comment.text),
59+
mentions: comment.mentions
60+
}),
5961
};
6062
const _listResults: SPHttpClientResponse = await spHttpClient.post(
6163
`${_endPointUrl}`,

0 commit comments

Comments
 (0)