-3
{URL}/text=Congratulations%21+You+are+eligible+for+.%0A

%0A = New line encoded character

I am passing encoded new line syntax in parameter. But the problem is that when I am building the above URL then its again encoded the % as %25 so above URL become {URL}/text=Congratulations%21+You+are+eligible+for+.%250A

I am not able to understand why URLBuilder encode already encoded character.

Used below code for building URLBuilder

URI url = new URIBuilder("URL").build();
Robin Green
  • 32,079
  • 16
  • 104
  • 187
Shiladittya Chakraborty
  • 4,270
  • 8
  • 45
  • 94
  • I don't know about that, but you could use Java 8's Base64 class (Base64.getUrlEncoder() etc) to encode your text in a way that will never be transformed further on the way through the system. It's wasteful because it doubles the length, but it's otherwise a one-size-fits-all solution. – Dreamspace President Apr 28 '18 at 15:05

2 Answers2

1

If you don't need url encoding why do you use URIBuilder at all? You could simply create a new URI.

0

You need #buildFromEncoded if you want to feed in pre-encoded strings.

Community
  • 1
  • 1
bmargulies
  • 97,814
  • 39
  • 186
  • 310