Recently I upgraded angular app 13 version to 14 version. I see some of the API calls failing which were working fine in angular 13.
API Call (Angular 13)
domain.com/api/v2/todos/count?filter=created+ge+1997-06-21
API Call (Angular 14)
domain.com/api/v2/todos/count?filter=created%2Bge%2B1997-06-21
"+" symbol replaced with "%2B" causing issue, Is there any way to send + in URL as is?
component.ts
const filter = "created+ge+1997-06-21"
service.todosCount(filter).subscribe()
service.ts
todosCount(params) {
return this.http.get<TodosCount[]>(
'/afes_case_api/v1/cases/state_count',{ params }
)
}
I've been thinking about your question and trying to learn what I can about it.
I believe that the issue you are having is with URL Encoding. This simply means that certain characters/symbols are restricted or "reserved". Source: [0]
"What does URL encoding do? URL Encoding (Percent Encoding)
URL encoding converts characters into a format that can be transmitted over the Internet. URLs can only be sent over the Internet using the ASCII character-set. Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format." Source: [1]
Below is a list of some useful sources if you want to do some further reading.
Source[0]: https://www.urlencoder.org/
Source[1]: https://www.url-encode-decode.com/
Source[2]: https://www.w3schools.com/tags/ref_urlencode.asp
Source[3]: https://help.marklogic.com/knowledgebase/article/View/using-url-encoding-to-handle-special-characters-in-a-document-uri
My Proposed Solution: Use unreserved characters to separate the information in the string. I believe the following characters will work without being encoded:
Alternative: I looked at rickz comment and I think it may be more useful if you want to keep the "+" symbol.