Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async static Task<bool> RegisterUser(usuarios user, string jsonString)
- {
- //llamaremos el metodo PostAsync mandandole el json
- HttpClient httpClient = new HttpClient();
- JsonObject jsonObject = JsonObject.Parse(jsonString);
- HttpStringContent httpStringContent = new HttpStringContent(jsonString, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json");
- Uri uri = new Uri("http://192.168.1.2/laravelplan/public/api/rest/users/store");
- HttpResponseMessage response = new HttpResponseMessage();
- try
- {
- response = await httpClient.PostAsync(uri, httpStringContent);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
- }
- if (!response.IsSuccessStatusCode)
- {
- string message = response.Content.ToString();
- MessageBox.Show(message, "error", MessageBoxButton.OK);
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement