0

How can i configure RestTemplate (Springframework) to encode using percent-encoding rather characters encoding, for example i am posting this parameters to a server:

client_id=xxx

client_secret=xxx

grant_type=client_credentials

scope=public_read registration

but when posting, spring send it as:

client_id=xxx&client_secret=xxx&grant_type=client_credentials&scope=public_read+registration

and i want it to be like that:

client_id=xxx&client_secret=xxx&grant_type=client_credentials&scope=public_read%20registration

it converts spaces to + and i want it to be %20

thx

1 Answers1

0

You can use this:

String formated_urlString = URLEncoder.encode(unformated_url_string, "utf-8").replace("+", "%20").

Also see URLEncoder not able to translate space character

Community
  • 1
  • 1
wolfaviators
  • 503
  • 1
  • 7
  • 21