loginButton.Clicked += (object sender, EventArgs e) =>
{
Login(email.Text, password.Text);
};
On button Click this method is being called -
public void Login(string username, string password)
{
string url = "http://192.168.1.6:8080/doc_register";
string contentType = "application/json";
JObject oJsonObject = new JObject();
oJsonObject.Add("name","myname");
oJsonObject.Add("gender", "male");
HttpClient oHttpClient = new HttpClient();
var oTaskPostAsync = oHttpClient.PostAsync(url, new StringContent(oJsonObject.ToString(), Encoding.UTF8, contentType)).Result;
if (oTaskPostAsync.IsSuccessStatusCode)
{
DisplayAlert("Account Created", "Head back to the hompage and login with your new account", "Ok");
}
else
{
DisplayAlert("Error Found", "", "Ok");
}
I am not able to return response I am getting in return. How can I print the response? Or How to create a async method for calling POST method on button click.