URI Encoding for RESTful Service

I am trying to call a java GET RESTful service with an email address from Ionic 2 (javascript). It works fine, however, when I add a dot (e.g. .com) to an email address, it loses all the characters from the dot when it reaches the service.

How do I encode a URI to send an email address to a service?

I use:

'/list/email/' + encodeURIComponent(email)

but if the email address is: email@domain.comit reaches the service like email@domain.

I tried:

'/list/email/' + email

'/list/email/' + encodeURI(email)

'/list/email/' + encodeURIComponent(email)

all give the same result

thank

+4
source share
3 answers

You can try to encode your email address for the Base64 string.

var encodedData = window.btoa("test@test.com"); // encode a string
var decodedData = window.atob(encodedData); // decode the string

How can you decode Base64 string on server

byte[] valueDecoded= Base64.decodeBase64(bytesEncoded);
System.out.println("Decoded value is " + new String(valueDecoded));
+1

FIX . '/' URL

return this.http.get(this.BASE_URI + '/list/email/' + email + '/')
+1

:

/somepath/{variable:.+}
0

Source: https://habr.com/ru/post/1652018/


All Articles