Advertisement
onzulin

registro de usuarios

Oct 24th, 2014
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. public async static Task<bool> RegisterUser(usuarios user, string jsonString)
  2.         {
  3.             //llamaremos el metodo PostAsync mandandole el json
  4.             HttpClient httpClient = new HttpClient();
  5.             JsonObject jsonObject = JsonObject.Parse(jsonString);
  6.             HttpStringContent httpStringContent = new HttpStringContent(jsonString, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json");
  7.             Uri uri = new Uri("http://192.168.1.2/laravelplan/public/api/rest/users/store");
  8.             HttpResponseMessage response = new HttpResponseMessage();
  9.            
  10.             try
  11.             {
  12.                 response = await httpClient.PostAsync(uri, httpStringContent);
  13.             }
  14.             catch (Exception ex)
  15.             {
  16.                 MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
  17.             }
  18.             if (!response.IsSuccessStatusCode)
  19.             {
  20.                 string message = response.Content.ToString();
  21.                 MessageBox.Show(message, "error", MessageBoxButton.OK);
  22.                
  23.             }
  24.             return true;
  25.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement