I have this function that I use for login requests.
private login(params: LoginParams): Promise<any> {
const loginHeaders: HttpHeaders = new HttpHeaders()
.set('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8')
.set('site', 'first');
const loginCredentials = new HttpParams()
.set('j_username', params.username)
.set('j_password', params.password);
const requestUrl = this.appConfig.baseUrl + 'restoftheurl';
return this.http
.post(requestUrl, loginCredentials.toString(),
{headers: loginHeaders, responseType: 'text'})
.toPromise();
}
If the password has a plus sign (+) in it, it is encoded into a space sign and then the request fails being a bad credential. How do I preserve the plus sign? What am I doing wrong?