Exemplo n.º 1
0
        private async Task <T1> PostAsync <T1, T2>(Uri requestUrl, T2 content)
        {
            addHeaders();
            var response = await _httpClient.PostAsync(requestUrl.ToString(), CreateHttpContent <T2>(content));

            response.EnsureSuccessStatusCode();
            var data = await response.Content.ReadAsStringAsync();

            return((T1)ConvertJson.Deserialize <T1>(data));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Common method for making GET calls
        /// </summary>
        private async Task <T> GetAsync <T>(Uri requestUrl)
        {
            addHeaders();
            var response = await _httpClient.GetAsync(requestUrl, HttpCompletionOption.ResponseHeadersRead);

            response.EnsureSuccessStatusCode();
            var data = await response.Content.ReadAsStringAsync();

            //return JsonConvert.DeserializeObject<T>(data);
            return((T)ConvertJson.Deserialize <T>(data));
        }