예제 #1
0
 public TemplateClient(
     string baseServiceUrl,
     System.Net.Http.HttpClient httpClient,
     ApimCredentials config) : this(baseServiceUrl, httpClient)
 {
     Config = config;
 }
예제 #2
0
        private void ConfigRequestApim(HttpClient httpClient, ApimCredentials apim)
        {
            string apiKey = "x-api-key";

            if (httpClient.DefaultRequestHeaders.Contains(apiKey))
            {
                httpClient.DefaultRequestHeaders.Remove(apiKey);
            }

            httpClient.DefaultRequestHeaders.TryAddWithoutValidation(apiKey, $"{apim.ApiKey}");

            string apiSubscription = "x-api-subscription";

            if (httpClient.DefaultRequestHeaders.Contains(apiSubscription))
            {
                httpClient.DefaultRequestHeaders.Remove(apiSubscription);
            }

            httpClient.DefaultRequestHeaders.TryAddWithoutValidation(apiSubscription, $"{apim.SubscriptionKey}");
        }