I doesn't see clearly why the consuming post api failed. it give me this exception while debugging:
[System.out] [OkHttp] sendRequest<< Thread finished: #11 Le thread 0xb s'est arrêté avec le code 0 (0x0).
This is the service:
public class MachineService : IMachineService
{
public string url = "url";
public async Task AddMachine(Machine machine)
{
try
{
HttpClient client = new HttpClient();
var response = await client.PostAsync(url,
new StringContent(JsonConvert.SerializeObject(machine), Encoding.UTF8, "application/json"));
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
and this is the post button method
private void Ajout(object sender, EventArgs e)
{
SaveMachine();
}
public async Task SaveMachine()
{
try
{
var machine = new Machine
{
Machine_Name = "amira",
Machine_Qr = "gazdallah"
};
await _rest.AddMachine(machine);
//await Shell.Current.GoToAsync("..");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}