Questions tagged [spring-resttemplate]
204 questions
1
vote
1 answer
Illegal unquoted character ((CTRL-CHAR, code 10))
I’m having issue consuming REST API. Below is my rest client. It fails at the service call with error:
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be…

alex
- 21
- 1
- 5
1
vote
2 answers
No suitable HttpMessageConverter found for response type [class java.lang.Boolean] and content type [application/json]
I am calling a rest endpoint in my code and the endpoint is returning a simple string "true" or "false". I have upgraded my spring boot to 2.4. The below code is now throwing an exception now.
ResponseEntity status =…

David Decanio
- 65
- 8
1
vote
1 answer
Decrease initial lag in webclient call
I am currently using Webclient of spring-webflux package to make synchronous REST calls.
But the time taken to mae the first request is longer than the time taken by RestTemplate.
I have observed that the successive calls take much lesser time and…

Manoj Majumdar
- 505
- 1
- 4
- 23
1
vote
1 answer
Spring RestTemplate works for String but not for my class
My problem is, if I call this URL and get a response with String, I got it, but with Class ESearchResult no. What I am doing here wrong? Please help...
String url =…

Andreja Vidovic
- 21
- 4
1
vote
1 answer
How to use Rest Template in Spring Boot Application to manage multiple endpoints?
In my Spring Boot Application I want to manage in only one method multiple endpoints.
These endpoints are declared in my application.yml in this way:
spring:
username: xxx
password: acb132
route:
source:
protocol: https://
…

guidop21
- 177
- 3
- 15
1
vote
2 answers
How to get json response in Java in case of 4XX and 5XX error
I was trying out RestTemplate and Retrofit2. Both the libraries throw exception in case api returns 4XX/5XX. The api when hit from postman gives a JSON response body, along with 4XX/5XX.
How can I retrieve this JSON response using RestTemplate or…

komsat
- 49
- 2
1
vote
0 answers
Add download progress RestTemplate in Java Spring
so I am downloading some files using Spring Rest template. I have a requirement to log the progress of the download in backend itself.
So can the download progress be logged in some way ?
Here is my implementation :
File file =…

Aryan Singh
- 11
- 1
1
vote
2 answers
How send request with query parameter "test[]=test" in spring?
I need to send get request to example.com/api with query param named test[]
For this i use spring rest tepmlate
UriComponentsBuilder builder = UriComponentsBuilder
.fromUriString(example.com/api)
.queryParam(test[],…

Pavel Bukhalov
- 53
- 7
1
vote
0 answers
How to deal with API call that can return different JSON data structure depending on result data
I am trying to write code using RestTemplate exchange to query an API that returns song info. The problem is that the data looks like this when data is found but
{"search":[{"song_id":"4R9o2J","song_title":"xxxx", ...}]
but like this if the song is…

philayoav
- 11
- 1
1
vote
1 answer
Error occured in RestTemplate Request Header too large for spring 4.1.3
How could I solve this in my spring web application? It is working in JDK 1.7, Spring 4.1.3 RELEASE and WebLogic 10 but when we upgrade JDK 1.8 , Spring 4.1.3 RELEASE and Weblogic 12.2 it is failing.
can we increase header size in RestTemplate.…

prakash sanap
- 11
- 1
- 1
- 3
1
vote
1 answer
Call a secure Rest api from spring boot
I have a spring boot application and i need to call a secure external api to retrieve data.
on below the steps I followed:
I generate the token with the username and password
I keep the token in a temporary variable
I use it on each resttemplate…

Achref Omrani
- 11
- 2
1
vote
1 answer
RestTemplate , Is there a way to retry a successful request after inspecting the response body?
Is there a way to retry a request that was successful ? All the examples are pointing to Retry behaviour when there is a failure on RestTempalte. I would like to send a request, wait for the response and inspect a field in the response and retry the…

rustylepord
- 5,681
- 6
- 36
- 49
1
vote
2 answers
Alfresco - How to add/set content of the file while doing post using RestTemplate
I am trying to upload a file to the DocLibrary folder using the below method:
private static void postTheDocument() {
final String restENDPoint =…

Ajay Kumar
- 2,906
- 3
- 23
- 46
1
vote
1 answer
JSON to CSV API with Spring RestTemplate
I want to hit a JSON to CSV API after grabbing a JSON from my own API. The JSON to CSV API requires email and JSON passed in a POST request. Now I am able to store JSON locally but, how do I pass in both the email and JSON in the request and how do…

Abhay
- 167
- 3
- 16
1
vote
1 answer
TestRestTemplate HttpHostConnectException: Connect to localhost:8082 [localhost/127.0.0.1] failed: Connection refused
I just clone source code from https://github.com/eugenp/tutorials/tree/master/spring-resttemplate and
can't execute test givenFooService_whenCallHeadForHeaders_thenReceiveAllHeaders() locally.
I received next…

dos4dev
- 429
- 2
- 10
- 26