In an Azure Function a static helper class uses RestSharp 106 like this:
public static class InsightlyHelper
{
private static readonly RestClient RestClient = new RestClient {
BaseUrl = new Uri(Environment.GetEnvironmentVariable("InsightlyApiBaseUrl") ?? throw new InvalidOperationException())
};
I switched to RestSharp 107 which uses the HttpClient and changed the code to this:
public static class InsightlyHelper
{
private static readonly RestClient RestClient = new RestClient(new Uri(Environment.GetEnvironmentVariable("InsightlyApiBaseUrl")));
But this error gets thrown: [Error] Failed to create new SUDB project for insightly project. Error was The type initializer for 'SU_API.Infrastructure.InsightlyHelper' threw an exception.
I have seen the Migration guide
I am thinking of trying to dependency inject RestClient to this helper class and another similar class, anyone tried that? Or other suggestions appreciated.