diff --git a/src/app/services/api.ts b/src/app/services/api.ts index 7787084566..22f84f30f7 100644 --- a/src/app/services/api.ts +++ b/src/app/services/api.ts @@ -283,7 +283,8 @@ export const api = { }, questions: { get: (id: string): AxiosPromise => { - return endpoint.get(`/pages/questions/${id}`); + // URL-encode the ID to handle special characters like pipe '|' in question IDs + return endpoint.get(`/pages/questions/${encodeURIComponent(id)}`); }, search: (query: QuestionSearchQuery): AxiosPromise => { return endpoint.get(`/pages/questions/`, { @@ -294,7 +295,9 @@ export const api = { id: string, answer: Immutable, ): AxiosPromise => { - return endpoint.post(`/questions/${id}/answer`, answer); + // URL-encode the ID to handle special characters like pipe '|' in question IDs + const encodedId = encodeURIComponent(id); + return endpoint.post(`/questions/${encodedId}/answer`, answer); }, answeredQuestionsByDate: ( userId: number | string,