Questions tagged [spring-resttemplate]

204 questions
1
vote
0 answers

Spring boot RestTemplate close connection for NULL responses results in ConnectionPoolTimeoutExceptions

We have a spring boot Application which makes RESTFul calls to a bunch of backends, one of them returns null reponses at times, and we are observing the connections are not released during these instances because of this code in RestTemplate…
1
vote
3 answers

curl request - changed to RestTemplate - No Body Error

I have a curl command, which is working fine, but when I am trying it in RestTemplate I am getting errors. Curl: curl -X POST "https://api.example.com/v1/tokens/accessToken" -H "accept: application/json" -H "Content-Type: application/json" -d "{ …
vicky
  • 890
  • 4
  • 23
  • 54
1
vote
2 answers

Spring Boot Actuator Shutdown Endpoint with Spring RestTemplate Client: Error 415 Unsupported Media Type

I was trying to run Spring Boot Microservices Tests, which are explained in this article: https://blog.codecentric.de/en/2017/02/integration-testing-strategies-spring-boot-microservices-part-2/ In these tests, Spring Boot Application is started and…
1
vote
1 answer

Spring boot RestTemplate.exchange give empty resultset with String.Class object

I'm using Spring boot version 2.1.3 and trying to make a rest call with RestTemplate. Please check the code below. final String uri = "https://devserver.slm.com/api/now/table/cmdb_ci_business_app"; RestTemplate restTemplate = new…
1
vote
0 answers

Spring Traverson follow relative path ignores baseUri

I'm trying to use Traverson in my Spring Boot application to consume an external HAL-api. While doing so I get the exception org.apache.http.ProtocolException: Target host is not specified on the first hop, i.e. Traverson calls my baseUri without…
1
vote
4 answers

Modify Response Body when implementing ClientHttpRequestInterceptor

I'm facing the following issue: I'm making a call to another service using a simple org.springframework.web.client.RestTemplate When calling it I need to intercept the request, modify the request body, and let it continue the flow. So far I don't…
Columb1a
  • 463
  • 2
  • 11
  • 25
1
vote
0 answers

ResponseBodyAsString missing while receiving HttpClientErrorException for POST call

I'm trying to send custom error message with Http status codes in RestClient call microservice 1 code: try{ String method = request.getMethod(); RestTemplate restTemplate = new RestTemplate(); ResponseEntity responseEntity =…
Giri
  • 31
  • 7
1
vote
0 answers

Java RestCall ByPass UserCredentials By Default

I find a way to pass current user credentials by default to my rest call in java.I start application by a specific user and I dont want to enter password information in my rest call(spring resttemplate or something similar to call a rest service) In…
Bilgehan
  • 1,135
  • 1
  • 14
  • 41
0
votes
1 answer

REST: openapi generation - response needs XML/JSON conversion while request is XML String

I'm building a client for an API where endpoint accepts XML for request (application/xml) and provides XML/JSON back in response (applicaiton/json, application/xml) At the moment of calling the API I already have the XML string to submit in the bode…
Milkywayfarer
  • 910
  • 1
  • 9
  • 25
0
votes
1 answer

spring kotlin restTemplate - how to parse JSON array inside response

I keep struggling with parsing response represented by a JSON array into a data class entity using Spring with Kotlin and RestTemplate. Non-array like responses are without an issue, ie. the following is just enough to work as expected: // JSON…
David Zaba
  • 67
  • 1
  • 9
0
votes
0 answers

Pass Authorization Header in OpenAPI Generator-generated Java WebClient Code

I have a Java/Spring-based microservices architecture with two services: A - has a public endpoint which does some stuff and then calls the below endpoint on B. This endpoint requires an Authorization header to identify the user. B - has an…
0
votes
1 answer

Java Spring RestTemplate getForObject response not decoded properly

I am trying to execute a HTTP GET request that I can execute properly in Postman in my Spring Boot application using the RestTemplate class. This is the code I am using to send the request: RestTemplate restTemplate = new RestTemplate(); String…
0
votes
0 answers

Preemptive Basic auth with Apache HttpClient 5.2

Is there a way to implement preemptive basic authentication with Apache HttpClient 5.2 using a HttpRequestInterceptor similar to how it's done here (accepted response) for Apache HttpClient 4? We use Apache HttpClient both directly and as the…
dascolagi
  • 107
  • 2
  • 12
0
votes
0 answers

How to resolve connection time out error in spring boot application?

I am trying to access external API from spring boot application in my local machine using external API's username and password but every times its giving error 'org.springframework.web.client.ResourceAccessException: I/O error on POST request for…
0
votes
0 answers

How to call https url using spring boot 3

I try to configure restTemplate to call https url in spring boot 3 but that does not compile. For this i use import org.apache.http.impl.client.HttpClients import org.apache.http.ssl.SSLContexts and the code below : fun restTemplate(): RestTemplate…
abdel
  • 7
  • 2