private async Task <R> HttpPost <R, T>(string path, T content = default(T), string queryString = "", string apiVersion = GeoMasterConstants.August2016Version, CancellationToken cancellationToken = default(CancellationToken))
        {
            var query    = SitePathUtility.CsmAnnotateQueryString(queryString, apiVersion);
            var response = new HttpResponseMessage();

            try
            {
                var uri  = path + query;
                var body = JsonConvert.SerializeObject(content);
                response = await _geoMasterClient.Client.PostAsync(uri, new StringContent(body, Encoding.UTF8, "application/json"), cancellationToken);

                response.EnsureSuccessStatusCode();
            }
            catch (TaskCanceledException)
            {
                if (cancellationToken != default(CancellationToken))
                {
                    throw new DataSourceCancelledException();
                }
                //if any task cancelled without provided cancellation token - we want capture exception in datasourcemanager
                throw;
            }

            if (typeof(R) == typeof(string))
            {
                return((await response.Content.ReadAsStringAsync()).CastTo <R>());
            }

            string responseContent = await response.Content.ReadAsStringAsync();

            R value = JsonConvert.DeserializeObject <R>(responseContent);

            return(value);
        }
        private async Task <R> PerformHttpRequest <R>(HttpMethod method, string path, string queryString, string content, string apiVersion, CancellationToken cancellationToken)
        {
            var query = SitePathUtility.CsmAnnotateQueryString(queryString, apiVersion);
            var uri   = new Uri(_geoMasterClient.BaseUri, path + query);
            HttpResponseMessage response = null;

            try
            {
                using (var request = new HttpRequestMessage(method, uri))
                {
                    try
                    {
                        if (method == HttpMethod.Post || method == HttpMethod.Put)
                        {
                            request.Content = new StringContent(content, Encoding.UTF8, "application/json");
                        }

                        var token = _geoMasterClient.AuthenticationToken;
                        if (!string.IsNullOrWhiteSpace(token))
                        {
                            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
                        }
                        response = await _geoMasterClient.Client.SendAsync(request, cancellationToken).ConfigureAwait(false);

                        response.EnsureSuccessStatusCode();
                    }
                    catch (TaskCanceledException)
                    {
                        if (cancellationToken != default(CancellationToken))
                        {
                            throw new DataSourceCancelledException();
                        }
                        //if any task cancelled without provided cancellation token - we want capture exception in datasourcemanager
                        throw;
                    }
                }

                R value;

                if (typeof(R) == typeof(string))
                {
                    value = (await response.Content.ReadAsStringAsync().ConfigureAwait(false)).CastTo <R>();
                }
                else
                {
                    string responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    value = JsonConvert.DeserializeObject <R>(responseContent);
                }
                return(value);
            }
            finally
            {
                if (response != null)
                {
                    response.Dispose();
                }
            }
        }