Questions tagged [spring-resttemplate]

204 questions
0
votes
1 answer

mock bean unable to inject dependecy in unit test

I want to test my spring boot application using TestRestemplate, however I am unable to test get url, what I am trying to do here is I am injecting some predefine objects setting into list and mocking find all method. below is my test code looks…
LowCool
  • 1,187
  • 5
  • 25
  • 51
0
votes
0 answers

How to send LocalDate in RestTemplate parameter

In below I called web service with String parameter named "samana" String samana= "000ABC"; RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); HttpEntity requestEntity = new HttpEntity(null,…
0
votes
2 answers

springboot RestTemplate call url and https response headers(content-type:audio/wav) ,how to save as *.wav file?

I use spring RestTemplate to call the the Third-party services, ResponseEntity forEntity = restTemplate.getForEntity(url, String.class); result like…
lin hiro
  • 3
  • 2
0
votes
1 answer

restTemplate BufferingClientHttpRequestFactory breaking cookies

I am calling another service using spring boot. When I have my configuration as follows, it does not add the jsessionid(cookie) returned from the service i am calling. public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) { …
Brian
  • 556
  • 6
  • 26
0
votes
0 answers

Create a large response body for a response entity

In order to test and replicate Out of Memory issue on my local system, I'm thinking of creating a huge response body ( in string format)which ideally should exceed the heap memory of JVM. Is it possible to create a very large string of around 2GB…
Sandy
  • 459
  • 2
  • 6
  • 19
0
votes
1 answer

Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal character ((CTRL-CHAR, code 31))

This is the full error message from my app logs Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between…
Chia Yi
  • 562
  • 2
  • 7
  • 21
0
votes
2 answers

Unable to catch error when using RestTemplate getForObject

I'm using RestTemplate to call my webservice's health actuator endpoint from another webservice of mine to see if the webservice is up. If the webservice is up, all works fine, but when it's down, I get an error 500, "Internal Server Error". If my…
Steve B
  • 557
  • 2
  • 7
  • 23
0
votes
1 answer

Getting no suitable HttpMessageConverter found for response type

org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [class net.minidev.json.JSONObject] and content type [application/json] public String…
Abhishek
  • 21
  • 1
  • 4
0
votes
1 answer

Calling RestTemplate APIs using custom Certificate and Key

I am calling an external API via RestTemplate that requires SSL Certificate. Already the external API provider has provided me with the certificate file (company.crt) and its key file (company.key). While adding the certificate, key and password in…
0
votes
1 answer

RestTemplate Get request with Brackets and Slash

I am using below URL with RestTemplate to get data http://localhost:8161/console/jolokia/exec/org.apache.activemq.artemis:broker="0.0.0.0"/listQueues/{"field":"","operation":"","value":""}/1/100 And my code looks like below HttpHeaders httpHeaders =…
0
votes
1 answer

How to convert a large JSON string to JSON Object?

My spring application does a rest request to a server and the response from the server is a JSONObject string. The JSON string is very huge(200MB). I want to convert the json string to a JSONObject. Below are my code for conversion: exchange =…
Prog_G
  • 1,539
  • 1
  • 8
  • 22
0
votes
0 answers

Unable to send request parameter using Spring RestTemplate client to HttpServeletRequest doPost

I am using Spring RestTemplate client to do a POST call to another application which handles this request as HTTpServletRequest. Problem is HTTpServletRequest is expecting a key value pair e.g. String xmlString =…
0
votes
1 answer

How to handle Status NOT FOUND in client service

I am new to developing microservice application backend. I am trying to fetch country details from other service in a spring boot microservice architecture. As part of Unit testing I am writing a negative test case where the CommonData mricroservice…
0
votes
1 answer

Spring rest template close connection if the data is more

I have a scenario where the http connection needs to be closed if the server is sending more data than expected. i.e after a few seconds of receiving the data, I would like the close the connection automatically. Is this feasible?
Vijay Muvva
  • 1,063
  • 1
  • 17
  • 31
0
votes
1 answer

How to test getting parameters on the Rest service using the Post method

I'm trying to test getting parameters for processing a request using the Post method @RestController @RequestMapping("api") public class InnerRestController { … @PostMapping("createList") public ItemListId createList(@RequestParam String…
skyho
  • 1,438
  • 2
  • 20
  • 47