encode some key's value of String URL for HTTP Get Request

199 views Asked by At

I need to encode only parameters of the string url. my string url is like: http://127.0.0.1:8070/app/api/fetchData?channel=abc&param=status:new|addr:null|roomId:Default&group=iPh&reqtype=p1&serialNo=123890&codeId=A1_8uh&type=p

I want to encode value of param(key).I am working on spring boot project. Please suggest some solution.

1

There are 1 answers

0
AAron On

If you're making the request from Java, you can encode a string using base64 like this[1]:

String originalInput = "test input";
String encodedString = Base64.getEncoder().encodeToString(originalInput.getBytes());

I guess my first thought would be to encode the parameters that you want this way and then concatenate the whole thing together. What value are you trying to get out of encoding the parameters?

[1] https://www.baeldung.com/java-base64-encode-and-decode