0

Small question regarding Spring Webflux WebClient please.

I have a netrc file at ~/.netrc The content is something like:

machine example.com
login abc
password qwerty

I use this netrc file in my curl command:

curl --netrc --insecure http://example.com:9876/API/abc

And I am getting the correct response, very happy.

I just need to migrate this curl command into Spring Webflux WebClient.

Therefore, I went to write this, here is what I tried:

final var webClient     = WebClient.create().mutate().defaultHeader("machine","example.com", "login", "abc", "password", "qwerty").clientConnector(new ReactorClientHttpConnector(HttpClient.create())).build();

final var response = webClient.post().uri("http://example.com:9876/API/abc").retrieve().bodyToMono(String.class).block();

Please note I put the content of the netrc file onto the WebClient header.

Unfortunately, I am getting 401 unauthorized.

The content of the netrc file, which I pasted onto the header, is for sure correct.

Therefore, I am having a hard time understanding why is it failing.

What did I do wrong please?

Thank you

PatPanda
  • 3,644
  • 9
  • 58
  • 154

0 Answers0