Ejemplo n.º 1
0
 public static string Get(string requestUri)
 {
     HttpResponseMessage response;
     try
     {
         response = AzHttpClient.httpClient.GetAsync(requestUri).Result;
         if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
         {
             ApiUser.RefreshToken();
             response = AzHttpClient.httpClient.GetAsync(requestUri).Result;
         }
     }
     catch (Exception e)
     {
         response = new HttpResponseMessage();
     }
     return response.Content.ReadAsStringAsync().Result;
 }
Ejemplo n.º 2
0
 public static string Put(string requestUri, string body)
 {
     StringContent post = new StringContent(body);
     post.Headers.ContentType.MediaType = "application/json";
     HttpResponseMessage response;
     try
     {
         response = AzHttpClient.httpClient.PutAsync(requestUri, post).Result;
         if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
         {
             ApiUser.RefreshToken();
             response = AzHttpClient.httpClient.PutAsync(requestUri, post).Result;
         }
     }
     catch (Exception e)
     {
         response = new HttpResponseMessage();
     }
     return response.Content.ReadAsStringAsync().Result;
 }