Questions tagged [spring-resttemplate]
204 questions
14
votes
5 answers
SpringBoot upgrade RestTemplateBuilder from 1.5.14 to 2.1.5
I have this piece of code working fine on a project that uses RestTemplateBuilder 1.5.14
this.restTemplate = restTemplateBuilder
.setConnectTimeout(connectTimeout)
.setReadTimeout(readTimeout)
…

Sandro Rey
- 2,429
- 13
- 36
- 80
5
votes
2 answers
Spring batch item writer rest API
Is it possible to read data from DB, process it and in ItemWriter send to another system using RestAPI (REST TEMPLATE) in Spring batch project? All I can see is fetch data and write it in a csv file.

shubham sharma
- 67
- 2
- 7
4
votes
1 answer
How can I avoid that RestTemplate put %20 in place of white space character into request query parameters?
I am working on a Spring Boot project using RestTemplate in order to perform a POST request toward an URL containing query parameter
This is my code:
@Override
public boolean insertNotaryDistrictDetailsAsPost(NotaryDistrictDetails notaryDistrict) {
…

AndreaNobili
- 40,955
- 107
- 324
- 596
4
votes
1 answer
Why is my integration test complaining about missing RestTemplate wiring in Spring Boot?
Why is my integration test complaining about missing RestTemplate wiring in Spring Boot ?
What can I do to fix this integration test?
Moreover, is this an integration test or a unit test? Based on my understanding this test is making a call to a…

Nital
- 5,784
- 26
- 103
- 195
3
votes
2 answers
Spring Boot 3 Micrometer Integration with RestTemplate
I have upgraded to spring boot 3. I am trying to instantiate metric binder with pool connection manager.
PoolingHttpClientConnectionManager connectionManager = new…

ayisha farhin
- 61
- 3
3
votes
1 answer
sending GET request via REST template with JSON request body getting failed with binding binding element must be a struct error?
I am trying to send a GET request using REST Template with a JSON request body, but the request is failing with error,
processing
failedorg.springframework.web.client.HttpServerErrorException$InternalServerError:
500 Internal Server Error:…

Muskan Agarwal
- 378
- 5
- 19
3
votes
2 answers
Java Jackson: Deserialize JSON with dynamic Names into JavaClass
I'm trying to deserialize JSON using jackson. The problem is that field names always change.
Here is an example JSON:
{
2021-08-02: [
{
label: "OnlineGallery",
nb_uniq_visitors: 1,
nb_visits: 2,
nb_events: 2,
…

Tanja298
- 33
- 3
3
votes
1 answer
Multiple RestTemplate calls for each Id in a List
I need to make multiple RestTemplate calls for each of the Id in a List. What is the best way to perform this?
I have used parallelStream(). Below code snippet is a similar scenario.
List…

Shubhashish
- 91
- 6
3
votes
0 answers
Difference between calling rest client asynchronously with webclient and @Async
I am planning to call an web rest endpoint asynchronously. Should i use webclient for all asynchronous invocation. OR can i use rest template and annotate the method with @Async. Will it still be invoked asynchronously.
Wats the differnce between…

VIJ
- 1,516
- 1
- 18
- 34
3
votes
1 answer
What can cause stale connection in Spring boot Restapi using RestTemplate
I read that "stale connections are a result of the server disconnecting the connection but the client not knowing." But i am trying to find how it is possible in case I am using my application based on SpringBoot RestTemplate (further using…

Sukh
- 424
- 5
- 16
2
votes
1 answer
Using MultipartFile to upload image to the server causes HttpClientErrorException$BadRequest: 400 Bad Request:
Taken from ThumbSnap
ThumbSnap offers a free API that can be used to upload and host images and videos programmatically.
This is the main API method used to upload images to ThumbSnap
Required fields:
media - Binary image/video data. Should be…

Crazy Coder
- 784
- 2
- 9
- 24
2
votes
0 answers
RestTemplate to WebClient
I'm migrating usage of RestTemplate to WebClient, following is my existing RestTemplate code,
val restTemplate: RestTemplate
@Throws(KeyStoreException::class, NoSuchAlgorithmException::class, KeyManagementException::class)
get() {
…

Vignesh
- 3,571
- 6
- 28
- 44
2
votes
0 answers
java.net.SocketException: Connection reset on External REST Calls
We do have following Configuration to build Spring beans.
Built configuration beans in Spring Beans with Connection Pool manager and ClosableHttpClient.
RestClient class autowires RestTemplate objects to make post calls.
import lombok.Data;
import…

sanssan
- 305
- 1
- 3
- 12
2
votes
0 answers
Class cast exception happened when resttemplate postforobject is mocked with MockK
I have an error when I mock restTemplate.postForObject method with a specific flavor of java.
With java version 11.0.11.j9-adpt:
o.mockk.MockKException: Class cast exception happened. Probably type information was erased. In this case use `hint`…

Hernan Ceballos
- 21
- 2
2
votes
1 answer
How to send Gzip Request using RestTemplate?
I have the following code with large pojo (MyRequest) which I wanted to send in Gzip, but it's unable to hit the end-point that accept Gzip request. Am I creating Gzip request correctly? Do I need to send the pojo as a file?
MyRequest request = new…

user1417746
- 191
- 2
- 3
- 11