Questions tagged [spring-resttemplate]

204 questions
2
votes
1 answer

How to send body in restTemplate as application/x-www-form-urlencoded

It is possible to set "application/x-www-form-urlencoded" in HttpHeader, but I want to set for requestbody, could you please guide me? sample json: "header": [ { "key": "Content-Type", …
Tohid Makari
  • 1,700
  • 3
  • 15
  • 29
2
votes
1 answer

Call Rest API by Spring RestTemplate within a @Async method

As I know, Spring RestTemplate is synchronous and blocks the thread until the web client receives the response, and Spring WebClient is asynchronous and non-blocking. But what if we call an API using RestTemplate within an @Async annotated…
2
votes
1 answer

Spring RestTemplate with JDK11 errors Posting data above certain limit

I am using OAuth2RestTemplate with JDK11 to make a POST request with Json data (860 lines and 26 KB). Strangely the code works fine with < 700 Json lines (or 20 KB) on production server and with < 500 lines (15 KB) on local machine. But as soon I…
2
votes
1 answer

Spring Boot Rest Template Proxy In Only Few Classes

My team is using RestTemplate to make external API calls. We need to configure the RestTemplate to use a proxy only in certain classes. In all other classes we want to avoid using the proxy. My first thought is to continue to @Autowire RestTemplate…
andresmonc
  • 398
  • 7
  • 21
2
votes
0 answers

Consume UTF-16 endpoint with restTemplate

I wrote a client application aimed to consume a remote XML service RestTemplate restTemplate = new RestTemplate(); restTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory("http://localhost/affettatrice")); …
Roberto Petrilli
  • 711
  • 1
  • 8
  • 22
2
votes
3 answers

JsonFormat$Value.hasLenient() Error on Rest Call

I'm building a set of microservices in Spring Boot. I've got one service which interfaces with the database and has a series of RESTful endpoints which other apps can hit. Many of these table entities are complex objects and are served up as a JSON…
Eyowzitgoin
  • 129
  • 2
  • 12
2
votes
1 answer

How to call secured rest api using .pfx certificate & password in spring boot rest template?

I need to invoke an external secured rest api(ssl enabled) from my spring boot application. The external api is accessible from postman using .pfx certificate & password. Now I would like to make a call to the external api using rest template by…
Abhijit Dutta
  • 29
  • 1
  • 3
1
vote
1 answer

How to implement test to check that actuator metrics are exist ? 404 for /actuator/prometheus in tests

I have a spring boot appication(version is 3.0.4): org.springframework.boot spring-boot-starter-parent 3.0.4 In application.yaml of…
1
vote
0 answers

Uploading List of Multipart files and other details in SpringBoot with RestTemplate

I'm working on a chain of microservice in Java where A microservice calls B and B in turn calls C(some external service). I need to call a method of C which accepts Multipart File and upload it to a location. Now in A microservice, I can have…
1
vote
1 answer

Is RestTemplate compatible with Spring Boot 3?

I'm trying to upgrade a legacy application to spring boot 3 and RestTemplate is used extesibly. As far as I know Spring Boot 3 doesn't allow blocking code (at least by default) and I was wondering if this behavior could be changed or the only…
1
vote
1 answer

Best practice to send the input request to POST endpoint

Iam creating a POST endpoint named /transactions which should accept the below input. What is the best practice to send the input request like the below? Should i use a request body or a input stream or a plain…
1
vote
1 answer

How to call Async API in Spring Boot using RestTemplate?

I am in a need of calling a api asynchronously in my spring boot application? Is there any methods that we can used in Spring RestTemplate?
1
vote
1 answer

RestTemplate postForEntity get List of DTOs

I has the same issue as mentioned in here. So I implemented my code as follows. String url = "http://localhost:8080/admin/user/find/all/email"+"?email={email}"; ResponseEntity> responseEntity = restTemplate.exchange( …
SjAnupa
  • 102
  • 10
1
vote
1 answer

How to handle ResourceAccessException in resttemplate using Spring integration

Here I'm using Spring integration's http outbound gateway to make a http call. I have also added timeout for the call. I have configured the timeout using restemplate. Here whenever it's taking more time then it's throwing an ResourceAccessException…
1
vote
0 answers

Spring Webclient block() method executing forever not returning value

I am working on oauth implementation, by following the https://developer.okta.com/blog/2021/05/05/client-credentials-spring-security It's a test client, I am getting the access token, but after calling actual end point with access token not…
1
2
3
13 14