2

Let's say I have an instance of HttpClient which is already configured. And now I want to use it for Flurl requests. I'd like to do something like this:

var poco = await httpClient.GetJsonAsync<POCO>();

Is this possible?

Prolog
  • 2,698
  • 1
  • 18
  • 31
  • Did you try? What happened? Did you get errors? Compile time or runtime? – nvoigt Jan 07 '20 at 15:51
  • 1
    Most common usage case of Flurl is calling extension method on string url, not on already existing instance of `HttpClient`. Flurl handles creation of `HttpClient` instance on its own. Hence my question. – Prolog Jan 07 '20 at 15:56

1 Answers1

2

Sure...

var flurlClient = new FlurlClient(httpClient);
var poco = await flurlClient.Request(url).GetJsonAsync<POCO>();
Todd Menier
  • 37,557
  • 17
  • 150
  • 173