0

I am getting Response too large when executing exchange (type POST) method from Spring Boot restTemplate. Below is the output

{"errors":[{"message":"Response too large","extensions":{"code":"413","responseSizeKb":1901.147,"responseSizeMaxKb":1000}}]}

I need to increase response size. Not sure how to do that.

Below are the code and httpHeaders

ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, this.getHttpEntity(), String.class, new Object[0]);


headers.add(Authorization, TOKEN_TYPE_BEARER + authKey);
headers.add(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
headers.setAccept(Arrays.asList(MediaType.ALL));
headers.add("Connection", "keep-alive");
headers.add("Cache-Control", "no-cache");

I tried to increase content-length but no luck

headers.add(HttpHeaders.CONTENT_LENGTH, "179974");

Can anyone please help me to increase response size ?

Dev
  • 11
  • 3
  • Is this error raised by Spring RestTemplate itself, or is the error produced by the server you are trying to connect to? Please add the complete exception. – larsgrefer Aug 14 '23 at 22:50
  • HI @larsgrefer Thanks for checking. Below is the output from resttemplate.exchange method.<200,{"errors":[{"message":"Response too large","extensions":{"code":"413","responseSizeKb":1901.147,"responseSizeMaxKb":1000}}]},[Date:"Mon, 14 Aug 2023 22:22:08 GMT", Content-Type:"application/json; charset=utf-8", Content-Length:"124", Connection:"keep-alive", server:"awselb/2.0", x-media-type:"application/vnd.hedtech.integration.v1.0.0+json", vary:"origin", access-control-expose-headers:"x-max-page-size,x-media-type,x-total-count,x-content-restricted,hedtech-ethos-integration-application-id, – Dev Aug 14 '23 at 22:53
  • looks like the server you are trying to connect has this "responseSizeMaxKb" settings. try adding more filters to reduce response data or increase value for "responseSizeMaxKb". – Maheshkumar Aug 15 '23 at 09:59

0 Answers0