public static void AddHttpClient(this IServiceCollection services, IConfiguration configuration) { TemplateConfig templateConfig = configuration.GetSection(TemplateConfig.TEMPLATE).Get <TemplateConfig>(); services.Configure <TemplateConfig>(configuration.GetSection(TemplateConfig.TEMPLATE)); HttpRestClient <DefaultHttpClientConfiguration <string> > apiClient = HttpRestClientFactory.Create <string>(templateConfig.BaseUrl, 3); apiClient.AddDefaultHeader(HttpRequestHeaders.ContentType, ContentTypes.ApplicationJson); apiClient.AddDefaultHeader(HttpRequestHeaders.Accept, ContentTypes.ApplicationJson); apiClient.AddDefaultHeader("Ocp-Apim-Subscription-Key", templateConfig.SubscriptionKey); apiClient.AddDefaultHeader("x-api-key", templateConfig.ApiKey); services.AddSingleton(apiClient); }