I'm facing the following issue:
I'm making a call to another service using a simple org.springframework.web.client.RestTemplate
When calling it I need to intercept the request, modify the request body, and let it continue the flow. So far I don't have problems as using org.springframework.http.client.ClientHttpRequestInterceptor
I can do whatever I want with my request (transforming RequestObjectA to requestObjectB before sending it to the service I'm calling).
Problem: How to modify the response body?
I see when calling ClientHttpResponse execute = clientHttpRequestExecution.execute(httpRequest, body)
I can get the body doing execute.getBody()
, so I can modify it, but I don't see a way to set it back somehow.
What could be a work around to set my modified body in a ClientHttpResponse
?