Questions tagged [spring-resttemplate]

204 questions
0
votes
0 answers

A request works with curl, but not with RestTemplate

I have a spring boot app, which uses Pinterest api. In order to exchange the auth code for the token, I need to send a post request like this one curl -c -v -X POST 'https://api.pinterest.com/v5/oauth/token' \ --header 'Authorization: Basic ...'…
Dknot
  • 63
  • 1
  • 8
0
votes
1 answer

@Mock RestTemplate not returning expected value

I am creating unit test for my service class: @Service @Slf4j public class SsaOpeningService { @Autowired private MockDataInitializer mockDataInitializer; @Qualifier("restHttpsTemplateClient") @Autowired private RestTemplate…
0
votes
1 answer

TLS Https error after upgrading Spring boot 2.3.2 to 2.5.12

We are getting this error after upgrading Spring boot 2.3.2 to 2.5.12 - while accessing Https rest endpoint org.springframework.web.util.NestedServletException: Request processing failed; nested exception is…
0
votes
1 answer

To access json response by calling exteranal api

{ "response": [ { "productId": "TP_PD_000011", "productName": "Toppr Get 10% Off on all Packages", "point": 100, "imageURL":…
user18578733
0
votes
1 answer

Java RestTemplate response mapping with nested list of objects

Hi I am hitting an endpoint with rest template and getting the response. When I use String as return type and print the response it's an XML response with multiple tags. and when I use Object as return type then RestTemplate is mapping only last…
0
votes
1 answer

Oauth2Restclient spring example - without springBoot

I am looking for a simple OAuth2restClient example (without SpringBOOT) I am trying with: ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails(); resource.setAccessTokenUri(…
0
votes
1 answer

How can I manipulate this JSON response obtained by RestTemplate to set a DTO object?

I am working on a Spring Boot application and I have the following problem. I have to set values of a simple DTO object from the JSON output retrieved from a REST call. Basically I am calling this GET API:…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
0
votes
0 answers

In a Spring-Boot integration test of a REST interface call, how can I roll back the server side transaction?

Given I am in a Springboot JUnit integration test which calls a REST controller method of the same spring application context using a TestRestTemplate, how can I make sure that the application server calls to the database are in the same transaction…
Kai
  • 2,145
  • 1
  • 20
  • 35
0
votes
0 answers

Rest API Calling Using Feign Client Vs RestTemplate

I want to call an API of the Spring Boot application from the my MVC Spring application. Is Feign Client or RestTemplate better for this API call and Why is it better?
Geeth
  • 541
  • 3
  • 12
0
votes
2 answers

How do I deserialize json into a single object from RestTemplate?

I have to use the exchange() method because I pass HttpHeaders there. ResponseEntity response Entity = restTemplate.exchange( weather UrlRequest, Http Method.GET, new HttpEntity<>(headers), WeatherResponse.class); JSON: { …
0
votes
0 answers

Response size configuration of RestTemplate

I have one get api that I'm calling internally in spring boot using RestTemplate. Everything is working fine except, If the response size is less then 10kb, there is no issue. But if the response size is greater then 10kb, RestTemplate is throwing…
Pirate
  • 2,886
  • 4
  • 24
  • 42
0
votes
0 answers

For HttpClient (org.apache.http.client), what does "A negative value is interpreted as undefined (system default if applicable)" mean?

When I look at the source code of HttpClient which in turn uses org.apache.http.client.config.RequestConfig, I see below - -taken from org.apache.http.client.config.RequestConfig.java /** * Determines the timeout in milliseconds until a…
0
votes
2 answers

how to verify http connection pool can improve performance

I want to use http connection pool with Spring RestTemplate, but before using it, I need to verify whether it can improve performance. I do a little programing here: @Configuration public class RestTemplateConfig { @Bean public RestTemplate…
richard
  • 1,845
  • 1
  • 20
  • 30
0
votes
0 answers

Why resttemplate is not throwing UnknownHttpStatusCodeException but java.lang.IllegalArgumentException?

Why resttemplate is not throwing UnknownHttpStatusCodeException but "java.lang.IllegalArgumentException: No matching constant for [0] while using RestTemplate" when an unknown http status code is received? eg: when RestTemplate.exchange() method…
Sukh
  • 424
  • 5
  • 16
0
votes
1 answer

Retry restTemplate pos on response body parameter

I'm making integration with a web service. There is an api post method that can return a "good" response with a body like: { "result": "Ok" } or if something bad happens it returns this: { "result": "Failure" } I need to retry the POS…
darth jemico
  • 605
  • 2
  • 9
  • 18