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
2
votes
1 answer
Why isn't my Spring WebFilter being applied to my webclient API requests?
I am trying to create a WebFilter for my Spring App's web client requests so that a token will be added within the headers of the request. It seems that my WebFilter isn't ever called since the println I've added in the filter is never printed…

Farhan Islam
- 609
- 2
- 7
- 21
2
votes
2 answers
How to return just a String using Webflux - webclient?
I would like to make this call and return a string
but I'm having this error:
"java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking,
which is not supported in thread reactor-http-nio-3"
I dont understand why am I doing…

Andres
- 731
- 2
- 10
- 22
2
votes
0 answers
WebClient - Flux - Content not getting created
I am trying to download a file form remote location using Spring WebClient and when I does that , the file is getting created but the content is not getting created. The File still remain 0KB. Any help ,
Flux dataBuffer = …

Susheel Rao
- 79
- 1
- 7
2
votes
0 answers
How to get response in Spring webclient
I have the following method which calls a rest api using webclient in a library.
public Flux getOffersByIds(List ids) {
return Flux.fromStream(batch(ids, 100)).flatMap(batch -> getOffersForBatch(batch));
}
private Mono…

cppcoder
- 22,227
- 6
- 56
- 81
2
votes
0 answers
Consume response from a WebClient API call in spring cloud gateway filter exchange
I am using Spring Cloud Gateway for my microservices and I am trying to make a blocking API call to another microservice within my GatewayFilter. But since spring cloud gateway is reactive, it does not allow for making blocking API Calls so I'm…

Ahmed Yusuf
- 73
- 7
2
votes
0 answers
How to handle HTTP 204 No Content Response in Spring
From my spring boot app I am making multiple calls to an API search service using the Spring Web Client. This is required due to pagination and multiple search params that cannot be used together.
When making calls with certain params I am getting…

Keibosh
- 1,237
- 1
- 9
- 18
2
votes
4 answers
How to solve "No converter for [class [B] with preset Content-Type 'image/png'" error in Spring when trying to serve an image?
I'm trying to build a spring controller which essentially acts as a reverse-proxy for a geoserver instance.
For example if the client wants to access geoserver/wms?PARAM1=foo&PARAM2=bar, the controller will simply forward the request to the actual…

Angela Lopez
- 73
- 11
2
votes
3 answers
How to deserialize the generic response using Spring WebClient
I have a problem during the deserialization of a response. Let's suppose I have this response from third party using webclient .
Response :
{
"name":"FirstName",
"type":"Steel",
"Fee":{
"id":"1234",
"name":"FeeFirstName"
},
…

Kumar Kartikeya
- 75
- 1
- 9
2
votes
1 answer
How to retrieve XML using webClient in Spring?
I've been trying to retrieve XML using webClient in Spring, but is has not worked out.
I've been getting this error message.
UnsupportedMediaTypeException: Content type 'application/xml;charset=UTF-8' not supported for bodyType
I think the request…

broaden-horizon
- 23
- 1
- 3
2
votes
0 answers
Spring Boot WebClient Sending Basic GraphQL POST Request As a Raw String
I'm trying to get even a basic query to send to my graphql server using WebClient, I have the following:
String query = "{ query: 'query testQuery { testData }' }";
String response =…

fairidox
- 3,358
- 2
- 28
- 29
2
votes
0 answers
useAbstractionForFiles OpenAPI WebClient not working
I am using OpenAPI generator (Gradle plugin version 5.4.0) to generate a few API calls. One of said calls, revolves a file download from an external service i.e my application calls that one and downloads and then should proxy the event. For that…

akortex
- 5,067
- 2
- 25
- 57
2
votes
1 answer
Java Spring Webflux - WebClient .onStatus((HttpStatus::isError) to return for error handling
Small Java Spring WebClient please.
I am the client application, making calls to a server. I am not the server, neither do I control anything on the server side. The server is known to be very flaky, and there is nothing I can do on the server…

PatPanda
- 3,644
- 9
- 58
- 154
2
votes
0 answers
Post request for an api works with restTemplate but throws proxy error with webClient
I'm trying to call an api with WebClient and it throws 404 with the below error message
{"fault":{"faultstring":"Unable to identify proxy for host: localhost:9943 and url:…

Priya
- 59
- 7
2
votes
2 answers
Mocking WebClient post method is failing
I could find several questions regarding mocking a WebClient object. But I still have problems when doing a post with a body and having multiple header values. I'm just using Mockito.
public Boolean addNote(AlarmModel model) {
ServiceDTO dto…

Swapnil
- 801
- 3
- 19
- 42
2
votes
0 answers
Am I not allowed to return response in exchangeToMono with Mono.just?
I want to return a header and body as a form of data responded from WebClient.
here is a code that I have tried
var res = webclient.post()
.uri(URI)
.accept(MediaType.APPLICATION_JSON)
…

co_lin
- 125
- 7