WebClient makes it possible to perform reactive non-blocking HTTP requests in Spring applications. Use this tag for any questions involving its usage.
Questions tagged [spring-webclient]
992 questions
13
votes
2 answers
How to use WebClient to execute synchronous request?
Spring documentation states that we have to switch from RestTemplate to WebClient even if we want to execute Synchronous HTTP call.
For now I have following code:
Mono> responseEntityMono = webClient.post()
…

gstackoverflow
- 36,709
- 117
- 359
- 710
13
votes
1 answer
WebClient's bodyToMono on Empty Body Expected Behavior
What is the expected behavior when WebClient bodyToMono encounters an empty body? In my specific example we are checking the status returned from a post call, and if it's an error converting it to our custom error format. If the conversion to the…

chas spenlau
- 325
- 1
- 2
- 12
12
votes
1 answer
Spring WebClient - how to retry with delay based on response header
A little background
I've been learning Spring Webflux and reactive programming and have gotten stuck on a problem I'm trying to solve around retry logic using Spring Webclient. I've created a client and made successful calls to an external…

LeagueGuyCoder
- 123
- 1
- 6
11
votes
3 answers
How to handle 404 in webclient retrive
I am new to spring webclient and i have written a generic method which can be used to consume rest apis in my application:
public List get(URI url, Class responseType) {
return WebClient.builder().build().get().uri(url)
…

Rohit Singh
- 145
- 1
- 2
- 7
11
votes
2 answers
How to use Spring WebClient without Spring Boot
I have a very limited need to be able to make HTTP request. I see WebClient is the new replacement for RestTemplate. But it seems it is impossible to use WebClient, without dragging in the whole of spring boot; which is not what I want to do. Any…

Finlay Weber
- 2,989
- 3
- 17
- 37
11
votes
1 answer
Spring WebClient and jsonPath - How to output json result if test fails
We are testing with WebTestClient (SpringBoot) our GraphQL Backend and have problems to see why exactly the test failed. Our code looks like this:
webTestClient
.post().uri(GQLKonstanten.URL)
.body(GQLRequestInserter.from(movieDeleteGQL,…

Janning Vygen
- 8,877
- 9
- 71
- 102
10
votes
3 answers
Spring Boot WebClient stops sending requests
I am running a Spring Boot app that uses WebClient for both non-blocking and blocking HTTP requests. After the app has run for some time, all outgoing HTTP requests seem to get stuck.
WebClient is used to send requests to multiple hosts, but as an…

wxker
- 1,841
- 1
- 6
- 16
10
votes
1 answer
Facing issue "WebClientRequestException: Pending acquire queue has reached its maximum size of 1000" with spring reactive webClient
I am running load of a microservice API, which involves calling other microservice API using Spring Reactive Webclient. I am using Postman runner tab to test this.
Firstly, i run the load with 1500 iteration, second microservice is getting called…

rajat behl
- 151
- 1
- 1
- 6
10
votes
1 answer
Catch exceptions with try/catch using Spring's WebClient with blocking/syncronous request
I need to make a syncronous, blocking request, and I'm using Spring's WebClient instead of Spring's RestTemplate due to the latter being deprecated. I don't need the reactive features in this case, I just want to consume a REST API in a…

afs35
- 359
- 1
- 2
- 14
10
votes
1 answer
How to set onStatus in Spring WebClient builder instance
I've got a lot of methods that use the onStatus API from Spring's WebClient:
@Override
public Mono createAccommodation(CreateAccommodation create) {
return webClient
.post()
.contentType(APPLICATION_JSON)
…

Andrea Damiani
- 611
- 1
- 6
- 20
9
votes
1 answer
Spring Boot WebClient Builder initialization in ServiceImpl Constructor
I am trying to follow the best practise of autowiring Webclient using WebClient Builder but little confused.
Here is my Main Application in which i am producing a Webclient Builder and autowiring it in one of my service class
…

Kamal Garg
- 107
- 1
- 2
- 9
9
votes
1 answer
Set Max In Memory Size In Spring Webflux
I am receiving the following error in a Spring Boot application using WebFlux
org.springframework.core.io.buffer.DataBufferLimitException: Exceeded
limit on max bytes to buffer : 262144
I tried setting the limit inside application.yml…

CDan
- 103
- 3
- 6
9
votes
3 answers
How to determine if Spring WebClient is using HTTP/2?
I would like to know whether Spring WebClient is using HTTP/2. How I can determine that?

pixel
- 24,905
- 36
- 149
- 251
8
votes
2 answers
Is it possible to include a request body in a GET request using Spring WebClient?
I know sending a body with a GET request isn't the best idea but I'm trying to consume an existing API which requires it.
Sending a body with POST is straight-forward:
webClient.post()
.uri("/employees")
.body(Mono.just(empl),…

MirekZelentFan
- 81
- 1
- 2
8
votes
1 answer
How should one do sync http requests in modern Spring?
For a long time, Spring has been recommending RestTemplate for sync http requests. However, nowadays the documentation says:
NOTE: As of 5.0 this class is in maintenance mode, with only minor requests for changes and bugs to be accepted going…

eis
- 51,991
- 13
- 150
- 199