Questions tagged [spring-resttemplate]
204 questions
0
votes
0 answers
Code refactor: CloseableHttpResponse to Resttemplate
I tried refactoring my code. After refactoring I am getting null response. Here is my older version of code:
import java.io.IOException;
import org.apache.http.client.methods.CloseableHttpResponse;
import…

piri
- 1
0
votes
2 answers
MultipartFile inside Custom Request / Response Objects
Can we send MultipartFile inside a Custom Request Object in a Rest Template call? Similarly, can we receive a MutlipartFile inside a Custom Response Object returned from a Rest call made through the Rest Template?
Basically, we need to send other…

Sabari
- 127
- 1
- 13
0
votes
0 answers
in java spring boot, RestTemplate.exchange change url
protected String requestData(String url,HttpEntity headers){
System.out.println(url);
return new RestTemplate().exchange(url, HttpMethod.GET,headers,String.class).getBody();
}
in this code, "System.out.println(url);"…

swz
- 63
- 6
0
votes
0 answers
ResourceAccessException vs HttpClientErrorException
I was trying to debug an issue where we were responding with 500 due to an unhandled exception while calling one of the downstream services. The exception which we were getting while calling the downstream service…

The-Proton-Resurgence
- 808
- 1
- 13
- 28
0
votes
0 answers
RestTemplate exchange call return result in XML format
We have two Microservice Services1 and Service2.
In Service1 we have one PostMapping and return boolean value as below.
@PostMapping
public boolean reset(){
return true
}
When consume from Service2 through restTemplate exchange method it will…

S. Anushan
- 728
- 1
- 6
- 12
0
votes
1 answer
500 Internal Server Error: [{"errors":["Unexpected character encountered while parsing value: %. Path '', line 0, position 0."]}]
I am using RestTemplate to call an AutoTask API. However I am getting an error that says: 500 Internal Server Error: [{"errors":["Unexpected character encountered while parsing value: %. Path '', line 0, position 0."]}]
Swagger UI screenshot of the…

Rajdeep Dodiya
- 1
- 1
- 4
0
votes
1 answer
Spring cloud gateway uri 413 too large when call happen
I am using microservices such as Frontend, resilience 4j api gateway and one is user microservice each service running in separate application in heroku.
When calling from frontend to api gateway service application's url, I'm getting 413 too large…

Ankit Srivastava
- 1
- 1
- 1
0
votes
1 answer
Encoding a URL Query Parameter so it can have a '+'
Apparently, in the move from Spring Boot 1 to Spring Boot 2 (Spring 5), the encoding behavior of URL parameters for RestTemplates changed. It seems unusually difficult to get a general query parameter on rest templates passed so that characters…

johnnyb
- 622
- 5
- 17
0
votes
2 answers
Using RestTemplate with JAXB annotations: list not recognized
I'm using RestTemplate in an application server project (not Spring Boot) to get an entity from an endpoint.
The entity DTO (using JAXB annotations) is:
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "entity")
public class EntityDTO {
…

italktothewind
- 1,950
- 2
- 28
- 55
0
votes
0 answers
How to solve NoHttpresponseException for Spring RestTemplate
I am using RestTemplate in order to invoke external REST APIs from my Spring boot application as follows:
@Bean("myRestTemplate")
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder
…

Joy
- 4,197
- 14
- 61
- 131
0
votes
1 answer
Spring RestTemplate POST method without body
I am trying to write a client in which I will do the POST method without body.
Is the only solution to insert null?
example:
client.exchange("/" + userId + "/logout", HttpMethod.POST, null, String.class);

sicio
- 117
- 1
- 6
0
votes
1 answer
Bad request with RestTemplate -> postForObject (Spring Boot)
I'm experiencing some troubles with a simple matter.
I'm trying to send a request to other REST service
//getting restTemplate from RestTemplateBuilder.build()
//endpoint and rest of variables came in properties
Map map = new…

Nacho Escursell
- 151
- 13
0
votes
1 answer
SSL Configuration for Http Client
this question might sound I bit dummy but I have researched many questions/answers here and can't find the answer for my case.
Currently I am using RestTemplate library to make HTTP requests for my java library that I am currently working on. In…

anirinamles
- 31
- 6
0
votes
1 answer
Convert RestTemplate Response to a new Format (SpringBoot): what is the correct approach?
I am consuming an external/third party api and I have created an endpoint in my SpringBoot application that currently returns its response via Spring REST API (RestTemplate). My ultimate goal is to re-structure the response and to do so I created…

panza
- 1,341
- 7
- 38
- 68
0
votes
1 answer
How to cast results to specific model type to access the field in that Model using spring test resttemplate in java?
Refer the below code, I am trying to cast the results to the Profile type model and iterating it to get the field. But I am getting class cast exception. Refer to the sample response attached below, Need to fetch pid from results.
//code
//…

selvi
- 1,271
- 2
- 21
- 41