0

When i use new instance of resttemplate like, ''' RestTemplate r = new RestTemplate();'''

And hit my service,i get success. But the moment i add,

'''Resttemplate r = new Resttemplate(); r.setRequestfactory(new HttpComponentsClientHttpRequestFactory());''' I start getting 400 bad request in get calls while post calls still working. I am using spring 6 and jdk 17 and apache httpclient5. Previously with spring 5.x and apache client 4,it was working fine.

vikas
  • 31
  • 6
  • Solution seems simple - if it works without, just don't use `HttpComponentsClientHttpRequestFactory` – Jorn Jul 20 '23 at 15:15
  • @Jorn i have given just for reference new object of HttpComponentsClientHttpRequestFactory, in real scenerio we are using connection pooling and timeouts with HttpComponentsClientHttpRequestFactory.So we cant really remove this requestfactory – vikas Jul 20 '23 at 15:23
  • How come 2 requestfactories making difference in rest api get calls.default is simplerequestfactory where as ours is HttpComponentsClientHttpRequestFactory – vikas Jul 20 '23 at 15:25
  • Well, they clearly produce different requests. You'll need to figure out what about the request is different. – Jorn Jul 20 '23 at 15:27
  • @jorn The request is a simple http get request accessible by browser and postman too.Its just a url which dont expect any headers or parameters.what should i compare in requestfactories?Also same call and same code works fine prior to upgrade to spring6 and springboot3.x – vikas Jul 20 '23 at 15:31

0 Answers0