0

I am having an application using Angular, which communicates with backend via rests. I am facing a problem with encoding of my questionares.

Angular part:

  searchCase(searchText: string): Observable<Case[]> {
    const encodedText = encodeURIComponent(searchText);
    return this.http.get<Case[]>(`${this.baseUrl}/case/search/${encodedText}`);
  }

Rest:

public List<Case> searchCase(
        @PathParam("searchedText") String searchedText) {
    return caseManagement.searchCase(searchedText);
}

For any input, this works totally fine, except for backslash. Then, it does not even reach my backend rest part. How can I go over it?

3

1 Answer 1

0

It turned out that it was enough to use btoa instead:

searchCase(searchText: string): Observable<Case[]> {
    const encodedText = btoa(searchText);
    return this.http.get<Case[]>(`${this.baseUrl}/case/search/${encodedText}`);
  }

And then decode it on backend side and seems to work totally fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.