Questions tagged [spring-webclient]

WebClient makes it possible to perform reactive non-blocking HTTP requests in Spring applications. Use this tag for any questions involving its usage.

992 questions
3
votes
2 answers

Spring Webclient : illegalargumentexception not enough variables to expand 'comment_count'

I am using spring webclient to make a Facebook graph api request with url containing {comment_count} But, getting this exception java.lang.IllegalArgumentException: Not enough variable values available to expand reactive spring Code Snippet :…
3
votes
1 answer

Webflux Webclient logs "Failed to release a message" when HttpStatus::is4xxClientError occurs

I'm trying to download a zip file from server using Webflux WebClient. What is the correct way to handle errors? When file exists on server, everything is OK. Otherwise, I got a warning from Netty that it couldn't release a message. return…
3
votes
0 answers

How to global error filter on Spring WebClient?

I want to add a global error filter to my WebClient, so that any exceptions and responses that are not 200 OK result in an exception. Problem: the following already works, but in case the url host connection is down completely…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
3
votes
1 answer

WebFlux WebClient loading entire file into direct buffer memory during multipart upload

I'm building an app with Spring Boot 2.1.6.RELEASE & Webflux We have an endpoint that we can upload files using multipart and are using WebClient for our uploads. Our upload client code looks like this @Component class UploadClient( private val…
Matthew Wilson
  • 2,045
  • 14
  • 27
3
votes
3 answers

How to override any HttpHeader in response of WebClient?

WebClient.builder().baseUrl("/").filter(contentTypeInterceptor()).build(); How can I modify the Content-Type of the received response (because I'm receiving a response from a webserver that emits the wrong content type. As I'm not in control of the…
membersound
  • 81,582
  • 193
  • 585
  • 1,120
3
votes
1 answer

What's the correct way to get the response body from a WebClient in an error case?

I'm new to WebClient and reactive programming. I want to get the response body from a request. In case of an error the http-code, headers and body must be logged, but the body should still be returned. After lots of digging and googling I found two…
BetaRide
  • 16,207
  • 29
  • 99
  • 177
3
votes
3 answers

How to make multiple Spring Webclient calls in parallel and wait for the result?

I am new to Reactive programming and I would like to make two API calls in parallel and process the results and return a simple array or list of items. I have two functions, one returns a Flux and the other returns a Mono and I make a very simple…
2
votes
1 answer

Send a huge json as a stream using Spring WebClient

I am new to Spring WebFlux and WebClient. I am working on a PoC where I have to send a huge JSON (> 100 MB) as a stream from microservice A to B using a POST request. The current implementation sends the entire json as the request body which leads…
2
votes
1 answer

Adding Dynamic Headers in @HttpExchange

I'm exploring Spring Boot 3. I created 2 REST services where one communicates with the other. Both are using Spring-starter-web and also imported Webflux. I found we can use @HttpExchange (My previous experience is Spring Boot 2.6 and also used only…
Coder
  • 6,948
  • 13
  • 56
  • 86
2
votes
1 answer

Spring security - using WebClient access a resource that is protected via Oauth2 "Password" grant type

How can I access with WebClient a resource that is protected via the Oauth2 'Password' grant type? Connecting with Oauth2 'client-credentials' works. In this case I need the password grant type. I get this error: 401 Unauthorized from GET…
tm1701
  • 7,307
  • 17
  • 79
  • 168
2
votes
2 answers

How to unit test the Spring WebClient in java?

I have this code which uses WebClient to call a third party API. public Mono callApi(String url) { return webClient.get() .uri(url) .headers(httpHeaders -> httpHeaders.set(Constants.X_API_KEY,…
Gojo
  • 151
  • 7
2
votes
0 answers

How to manage tracing with Spring WebClient in Reactive way?

I have a method in EventService that calls an API and handle errors if there is any. private Mono send(String accountId) { accountIdBaggageField.updateValue(accountId); logger.info("making the call"); Mono res =…
2
votes
1 answer

Spring WebFlux - FilePart forward via webClient

I went through similar tickets (i.e. How to stream file from Multipart/form-data in Spring WebFlux), but apparently I have slightly different case. High-level example (no error handling / no 'empty' checks): Controller: @ResponseStatus(code =…
asceta
  • 272
  • 1
  • 4
  • 10
2
votes
1 answer

Is it possible to use Spring Webclient to post files to an endpoint expecting application/json without reading the files into memory?

I'm trying to POST to an endpoint that looks like this: @PostMapping("/endpoint", consumes="application/json") public ResponsePojo post(final @RequestBody UploadPojo uploadPojo) { ... } Where the request body looks like this: public class…
billoot
  • 77
  • 15
2
votes
0 answers

Upload file to AWS S3 using presigned URL via Spring webclient error: "the Credential is mal-formed"

I'm using reactive spring and trying to upload a ".csv" file into AWS S3 using a presigned URL. I spring webclient for this and my code snippet as below Webclient bean @Bean public WebClient webClient(WebClient.Builder webClientBuilder)…