0

Using Flurl, I am trying to implement an elegant solution to handle 401 responses for several APIs.

I can trap HTTP exceptions using:

FlurlHttp.GlobalSettings.OnError = MyFlurlErrorHandler;

And then:

private void MyFlurlErrorHandler(HttpCall httpCall)
{
    if (httpCall.HttpStatus == System.Net.HttpStatusCode.Unauthorized)       //401
    {
         //some code here will refresh our access token to take care of the 401 error

         //SESSION MANAGEMENT HERE
         httpCall.ExceptionHandled = true
    }
}

Once the error is handled, how do I automatically retry the original httpCall here before setting ExceptionHandled = true?

TheFunk
  • 981
  • 11
  • 39

1 Answers1

0

Flurl has nothing built-in to do retries, although it is on the roadmap. Until then I recommend using Polly.

Todd Menier
  • 37,557
  • 17
  • 150
  • 173