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
3
votes
1 answer
WebFlux WebClient with Generic Types
I'm trying to make a Client Library with WebClient from Spring WebFlux.
Server return responses like this JSON:
{
"result": [
{
"parent": "",
"made_sla": "true",
"watch_list": "",
"upon_reject": "cancel",
…

OscarRP
- 85
- 2
- 10
3
votes
1 answer
Disabling SSL checking for Spring web-client
The following code is what I am using to try and build a web client instance that can talk to a https server with an invalid certificate.
SslContext sslContext = SslContextBuilder
.forClient()
…

B Shannon
- 61
- 6
3
votes
0 answers
Exception Handling in Springboot with openapi: "3.0.2"
I am trying to handle exceptions within my downloadfile Api. I am using openapi: "3.0.2" in springboot service. I tried implementing controlleradvice but OPEN API is not supporting Controlleradvice. Could you please suggest a standard approach or…

Hank
- 31
- 1
- 3
3
votes
2 answers
Using Spring WebClient to upload a file in java
I am trying to migrate from normal HttpPost methods to Spring WebClient and I have an API that accepts two files (one JSON and one PDF) for upload.
I am trying to send the files like below, but getting a 500 Internal Server Error instead of the 200…

V.Aggarwal
- 557
- 4
- 12
3
votes
1 answer
Reactive Programming: Spring WebFlux: How to build a chain of micro-service calls?
Spring Boot Application:
a @RestController receives the following payload:
{
"cartoon": "The Little Mermaid",
"characterNames": ["Ariel", "Prince Eric", "Sebastian", "Flounder"]
}
I need to process it in the following way:
Get the unique Id…

user471011
- 7,104
- 17
- 69
- 97
3
votes
0 answers
Authorization required for Client Registration Id
I'm trying to setup an API that needs to comunicate with another service that requires the server to login using OAuth2.
I have the following files/configuration:
@Configuration
public class WebClientConfig {
@Bean
WebClient…

dup65658
- 31
- 2
3
votes
2 answers
Spring WebClient - how to access response body in case of HTTP errors (4xx, 5xx)?
I want to re-throw my exception from my "Database" REST API to my "Backend" REST API but I lose the original exception's message.
This is what i get from my "Database" REST API via Postman:
{
"timestamp": "2020-03-18T15:19:14.273+0000",
…

Dimitri
- 81
- 1
- 1
- 6
3
votes
1 answer
Adding new header when retrying with Spring WebClient
webclientbuilder.baseUrl(url)
.defaultHeaders(headers -> headers.addAll(requestHeader))
.build()
.post()
.uri("/uri")
.bodyValue(data)
.exchange()
…

xBentu
- 41
- 3
3
votes
2 answers
Parallel GET Request to specific mapping with WebFlux
I want to call independent request simultaneously with WebClient. My previous approch with RestTemplate was blocking my threads while waiting for the response. So I figured out, that WebClient with ParallelFlux could use one thread more efficient…

froehli
- 904
- 1
- 11
- 35
3
votes
1 answer
Webclient map nested object
I'm using WebClient to consume ai API
The node I need from the response is nested inside
example API response
{
"api": {
"results": 129,
"countries": [
{
"country": "Albania",
"code":…

Bruno Miguel
- 1,003
- 3
- 13
- 26
3
votes
1 answer
replacing an OAuth2 WebClient in a test
I have a small Spring Boot 2.2 batch that writes to an OAuth2 REST API.
I have been able to configure the WebClient following https://medium.com/@asce4s/oauth2-with-spring-webclient-761d16f89cdd and it works as expected.
@Configuration
…

Vincent F
- 6,523
- 7
- 37
- 79
3
votes
1 answer
Spring WebClient: Automatically compute HMAC signature for body and pass it as header
In my Spring Boot application, I was using RestTemplate to call a WS for which the body HMAC signature should be provided as HTTP header. To do this I was using a ClientHttpRequestInterceptor. Basically, I did:
@Override
public ClientHttpResponse…

Loïc
- 560
- 1
- 3
- 12
3
votes
0 answers
How to log spring webclient request and response body?
added an ExchangeFilterFunction to WebClient which logs request and response but while logging, was unable to log request and response body as a string or JSON. It prints as an object
Tried different castings and retrieving the body as a string…

Munni
- 79
- 1
- 7
3
votes
2 answers
Are there Java classes for Camunda Rest responses?
Im currently trying to set up REST calls from Spring to my local camunda instance using the camunda rest api.
Here's how i've set it up:
Started a local camunda docker container on my localhost:8080 like this:…

Bishares
- 67
- 1
- 13
3
votes
2 answers
How to initialize WebClient using constructor base initialization in java?
I tried to replace RestTemplate from WebClient because according to the Java Doc the RestTemplate will be deprecated. Spring team advises using the WebClient if possible.
previous code with RestTempalte is as follows
public Map…

Dilanka Gunarathna
- 41
- 1
- 6