0

my POST request looks like this:

const loginParam = new HttpParams()
.set('Username', 'myUser')
.set('Password', ':(7vHa%+_(Tbc+m@');

this.http.post('/post', loginParam).subscribe(value => {
  console.log('success');
}, error => {
  console.log('error');
});

The server replies (status code 500) that the login was unsuccessful. Can it be that the password is not sent correctly? In the following a snippet from the devtools:

View Form Data (the password seems to be wrong - the plus sign has disappeared)

view form data

Is it possible that the server gets an incorrect password? Everything works without problems with Postman.

eftas
  • 139
  • 5
  • Do you have access to the server component? So you could try to encode your password with `encodeURI()` before sending the password and decode it in the server component before you hand it over to the real login method. – John Archer Jan 21 '20 at 12:12
  • @JohnArcher Unfortunately I have no access to the server. – eftas Jan 21 '20 at 13:38
  • 1
    Ok. Does this help you? -> https://stackoverflow.com/a/22671551 And here is a post with a similar problem (unfortunately no anwer): https://stackoverflow.com/questions/42023170/angular2-http-post-request-parameters-prevent-encoding-the-special-characters – John Archer Jan 21 '20 at 13:54
  • 1
    @JohnArcher Thanks for the hints. I found a post that solves my problem. https://stackoverflow.com/questions/53546691/preserving-plus-sign-in-urlencoded-http-post-request – eftas Jan 21 '20 at 14:05

1 Answers1

1

I found a post that solves my problem:

Preserving + (Plus Sign) in URLEncoded Http Post request

Now, everything works like a charme.

eftas
  • 139
  • 5