I have this Spring REST controller method:
@ApiOperation(\"My method\")
@RequestMapping(method = RequestMethod.POST, value = \"/myMethod\")
public void myMethod(
A +
usually means a space in url params. This is a standard. Your url gets generated on below line of code
final BodyBuilder requestBuilder = RequestEntity.method(method, builder.build().toUri());
And +
is not encoded as it is a valid value to have which will be then later converted to space at the receiving end. Now when you try use %2B
the above line of code sees that you have a un-encoded %
character and it converts it to %252B
.
When you receive this back at Spring it converts it back to %2B
for you. One way to solve the issue is to send encoded values yourself. So you will change
final BodyBuilder requestBuilder = RequestEntity.method(method, builder.build().toUri());
to
final BodyBuilder requestBuilder = RequestEntity.method(method, builder.build(true).toUri());
And then call the API method as
client.myMethod("tarun%2blalwani")
And now spring will receive tarun+lalwani
as shown below