title: SpringBoot how to Send response to other URL
body: <p>I have the following code:</p>
  
  <pre><code>@RequestMapping(
              consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE},
              path = "api/api1",
              method = RequestMethod.POST,
              produces = MediaType.ALL_VALUE
      )
      public ResponseEntity&lt;?&gt; api1CallBack(@RequestBody String requestBody, HttpServletRequest request) throws IOException, GeneralSecurityException, URISyntaxException {
         String response="{SOME_JSON}";
          URI callbackURL = new URI("http://otherAPIEnv/api2");
          HttpHeaders httpHeaders = new HttpHeaders();
          httpHeaders.setLocation(callbackURL);
          return new ResponseEntity&lt;String&gt;(response,httpHeaders, HttpStatus.OK);
      }
  </code></pre>
  
  <p>I tried the above code, but when I hit the api1 through my curl I get the response on the same machine, but I want the response to be redirected to api2 at otherAPIEnv machine.</p>
  
  <p>Could someone please suggest how to achieve this kind of request and response?</p>