I use the requestFilter in WebClient and use the ExchangeFilterFunctions.basicAuthentication to perform basic authentication as described in the documentation. I use Spring Security's httbasic() to do server security authentication, but the result is still 401 authentication failure.
Some questions that might be easy to verify in your setup.. Does the same server and endpoint (POST /upload) work when using some other client (e.g. RestTemplate or with "curl --user admin:admin")? If so, is the Authentication header different?
I am unable to reproduce the issue. In my sample it works for GET and POST.
when I used 'get' request ,can success pass basic,but 'post' not
That confirms the Authorization header is sent correctly, but for some reason the server rejects HTTP POST. Check your Spring Security confirmation for anything that might explain this. Whatever the issue may be, it is unlikely to have anything to do with the WebClient since all it has to do is insert one header, which is trivial, and is verified by tests.