Exemplo n.º 1
0
 public virtual void SetRequestBody(HttpRequestMessage requestMessage, object obj)
 {
     if (obj != null)
     {
         requestMessage.Content = new StringContent(NewtonJson.Serialize(obj), Encoding.UTF8, "application/json");
     }
 }
Exemplo n.º 2
0
        public async Task <T> GetAsync <T>(string path, Dictionary <string, string> queries)
        {
            try
            {
                var requestMessage  = InitRequest(HttpMethod.Get, path, queries);
                var responseMessage = await SendAsync(requestMessage).ConfigureAwait(false);
                await PreprocessResponse(responseMessage);

                string bodyText = await responseMessage.Content.ReadAsStringAsync();

                return(NewtonJson.Deserialize <T>(bodyText));
                //return NewtonJson.Deserialize<T>(bodyText,JsonSettings.Snake);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(default);