0

I am trying to access external https API via my spring boot application using RestTemplate. When I send first request then I get the correct response and after that whenever send request then I get 400 bad response error.

But when I restart my application then again only for the first request I get correct response after that 400 bad response error.

public void getResponse(RequestBody, requestBody){

Response response = null;

Proxy proxy = new Proxy(Type.HTTP, new InetSocketAddress(PROXY_SERVER_HOST, PROXY_SERVER_PORT));
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setProxy(proxy);

RestTemplate restTemplate = new RestTemplate(requestFactory);
restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor("user", "password"));
response = restTemplate.postForObject("URL", requestBody, Response.class);
System.out.println(response.toString());
}

How can i resolve this issue ?

Rahul
  • 111
  • 3
  • 13

0 Answers0