public void ConfigureHttpClient() { if (!httpClient.DefaultRequestHeaders.Contains("Accept")) { httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); } if (!httpClient.DefaultRequestHeaders.Contains("OData-MaxVersion")) { httpClient.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0"); } if (!httpClient.DefaultRequestHeaders.Contains("OData-Version")) { httpClient.DefaultRequestHeaders.Add("OData-Version", "4.0"); } if (CallerId != Guid.Empty && !httpClient.DefaultRequestHeaders.Contains("MSCRMCallerID")) { httpClient.DefaultRequestHeaders.Add("MSCRMCallerID", CallerId.ToString()); } if (!httpClient.DefaultRequestHeaders.Contains("Prefer")) { httpClient.DefaultRequestHeaders.Add("Prefer", "odata.include-annotations=\"*\""); } httpClient.Timeout = Timeout; }
private void RefreshCallerId() { if (httpClient?.DefaultRequestHeaders?.Contains("MSCRMCallerID") ?? false) { httpClient.DefaultRequestHeaders.Remove("MSCRMCallerID"); } if (CallerId != Guid.Empty) { httpClient?.DefaultRequestHeaders?.Add("MSCRMCallerID", CallerId.ToString()); } }